2015-04-26 02:32:03 +00:00
|
|
|
|
using CsQuery;
|
2015-07-19 00:27:41 +00:00
|
|
|
|
using Jackett.Models;
|
2015-07-19 17:18:54 +00:00
|
|
|
|
using Jackett.Services;
|
2015-07-19 00:27:41 +00:00
|
|
|
|
using Jackett.Utils;
|
2015-07-27 00:03:51 +00:00
|
|
|
|
using Jackett.Utils.Clients;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2015-07-19 00:27:41 +00:00
|
|
|
|
using NLog;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Web;
|
2015-08-03 21:38:45 +00:00
|
|
|
|
using Jackett.Models.IndexerConfig;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
|
|
|
|
namespace Jackett.Indexers
|
|
|
|
|
{
|
2015-07-19 17:18:54 +00:00
|
|
|
|
public class TorrentLeech : BaseIndexer, IIndexer
|
2015-04-26 02:32:03 +00:00
|
|
|
|
{
|
2015-07-27 00:03:51 +00:00
|
|
|
|
private string LoginUrl { get { return SiteLink + "user/account/login/"; } }
|
|
|
|
|
private string SearchUrl { get { return SiteLink + "torrents/browse/index/query/{0}/categories/2%2C26%2C27%2C32/orderby/added?"; } }
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-08-03 21:38:45 +00:00
|
|
|
|
new ConfigurationDataBasicLogin configData
|
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataBasicLogin)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-07 19:09:13 +00:00
|
|
|
|
public TorrentLeech(IIndexerManagerService i, Logger l, IWebClient wc, IProtectionService ps)
|
2015-07-19 23:05:30 +00:00
|
|
|
|
: base(name: "TorrentLeech",
|
|
|
|
|
description: "This is what happens when you seed",
|
2015-07-27 00:03:51 +00:00
|
|
|
|
link: "http://www.torrentleech.org/",
|
2015-08-11 18:48:25 +00:00
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
2015-07-19 23:05:30 +00:00
|
|
|
|
manager: i,
|
2015-07-27 00:03:51 +00:00
|
|
|
|
client: wc,
|
2015-08-03 21:38:45 +00:00
|
|
|
|
logger: l,
|
2015-08-07 19:09:13 +00:00
|
|
|
|
p: ps,
|
2015-08-03 21:38:45 +00:00
|
|
|
|
configData: new ConfigurationDataBasicLogin())
|
2015-04-26 02:32:03 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task ApplyConfiguration(JToken configJson)
|
|
|
|
|
{
|
2015-08-03 21:38:45 +00:00
|
|
|
|
configData.LoadValuesFromJson(configJson);
|
2015-04-26 02:32:03 +00:00
|
|
|
|
var pairs = new Dictionary<string, string> {
|
2015-08-03 21:38:45 +00:00
|
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
|
{ "password", configData.Password.Value },
|
2015-04-26 02:32:03 +00:00
|
|
|
|
{ "remember_me", "on" },
|
|
|
|
|
{ "login", "submit" }
|
2015-08-03 21:38:45 +00:00
|
|
|
|
};
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-08-03 21:38:45 +00:00
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl);
|
2015-08-02 17:28:59 +00:00
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("/user/account/logout"), () =>
|
2015-04-26 02:32:03 +00:00
|
|
|
|
{
|
2015-07-27 00:03:51 +00:00
|
|
|
|
CQ dom = result.Content;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
var messageEl = dom[".ui-state-error"].Last();
|
|
|
|
|
var errorMessage = messageEl.Text().Trim();
|
2015-08-03 21:38:45 +00:00
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
2015-07-27 00:03:51 +00:00
|
|
|
|
});
|
2015-04-26 02:32:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-28 23:10:04 +00:00
|
|
|
|
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2015-04-26 02:32:03 +00:00
|
|
|
|
{
|
2015-07-28 23:10:04 +00:00
|
|
|
|
var releases = new List<ReleaseInfo>();
|
2015-07-18 20:35:02 +00:00
|
|
|
|
var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString();
|
|
|
|
|
var episodeSearchUrl = string.Format(SearchUrl, HttpUtility.UrlEncode(searchString));
|
2015-07-29 17:47:51 +00:00
|
|
|
|
var results = await RequestStringWithCookiesAndRetry(episodeSearchUrl);
|
2015-07-18 20:35:02 +00:00
|
|
|
|
try
|
2015-04-26 02:32:03 +00:00
|
|
|
|
{
|
2015-07-27 00:03:51 +00:00
|
|
|
|
CQ dom = results.Content;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
CQ qRows = dom["#torrenttable > tbody > tr"];
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
foreach (var row in qRows)
|
|
|
|
|
{
|
|
|
|
|
var release = new ReleaseInfo();
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
var qRow = row.Cq();
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
var debug = qRow.Html();
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
release.MinimumRatio = 1;
|
|
|
|
|
release.MinimumSeedTime = 172800;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
CQ qLink = qRow.Find(".title > a").First();
|
2015-07-19 17:18:54 +00:00
|
|
|
|
release.Guid = new Uri(SiteLink + qLink.Attr("href"));
|
2015-07-18 20:35:02 +00:00
|
|
|
|
release.Comments = release.Guid;
|
|
|
|
|
release.Title = qLink.Text();
|
|
|
|
|
release.Description = release.Title;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-19 17:18:54 +00:00
|
|
|
|
release.Link = new Uri(SiteLink + qRow.Find(".quickdownload > a").Attr("href"));
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-23 21:14:36 +00:00
|
|
|
|
var dateString = qRow.Find(".name")[0].InnerText.Trim().Replace(" ", string.Empty).Replace("Addedinon", string.Empty);
|
2015-07-18 20:35:02 +00:00
|
|
|
|
//"2015-04-25 23:38:12"
|
|
|
|
|
//"yyyy-MMM-dd hh:mm:ss"
|
2015-07-23 21:14:36 +00:00
|
|
|
|
release.PublishDate = DateTime.ParseExact(dateString, "yyyy-MM-ddHH:mm:ss", CultureInfo.InvariantCulture);
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-26 03:53:53 +00:00
|
|
|
|
var sizeStr = qRow.Children().ElementAt(4).InnerText;
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
2015-04-26 02:32:03 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".seeders").Text());
|
|
|
|
|
release.Peers = release.Seeders + ParseUtil.CoerceInt(qRow.Find(".leechers").Text());
|
2015-05-04 04:12:14 +00:00
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
releases.Add(release);
|
2015-04-26 02:32:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-18 20:35:02 +00:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2015-07-27 00:03:51 +00:00
|
|
|
|
OnParseError(results.Content, ex);
|
2015-07-18 20:35:02 +00:00
|
|
|
|
}
|
2015-05-04 04:12:14 +00:00
|
|
|
|
|
2015-07-28 23:10:04 +00:00
|
|
|
|
return releases;
|
2015-04-26 02:32:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|