mirror of
https://github.com/Jackett/Jackett
synced 2025-01-01 04:38:20 +00:00
parent
16a59b8abd
commit
f16ee42f7d
1 changed files with 65 additions and 84 deletions
|
@ -19,37 +19,34 @@ namespace Jackett.Common.Indexers
|
|||
{
|
||||
public class TorrentLeech : BaseWebIndexer
|
||||
{
|
||||
private string LoginUrl => SiteLink + "user/account/login/";
|
||||
private string SearchUrl => SiteLink + "torrents/browse/list/";
|
||||
private new ConfigurationDataRecaptchaLogin configData => (ConfigurationDataRecaptchaLogin)base.configData;
|
||||
|
||||
public override string[] LegacySiteLinks { get; protected set; } =
|
||||
{
|
||||
"https://v4.torrentleech.org/",
|
||||
};
|
||||
|
||||
private string LoginUrl => SiteLink + "user/account/login/";
|
||||
private string SearchUrl => SiteLink + "torrents/browse/list/";
|
||||
|
||||
private new ConfigurationDataRecaptchaLogin configData
|
||||
{
|
||||
get => (ConfigurationDataRecaptchaLogin)base.configData;
|
||||
set => base.configData = value;
|
||||
}
|
||||
|
||||
public TorrentLeech(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps)
|
||||
: base(name: "TorrentLeech",
|
||||
description: "This is what happens when you seed",
|
||||
link: "https://www.torrentleech.org/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
downloadBase: "https://www.torrentleech.org/download/",
|
||||
configData: new ConfigurationDataRecaptchaLogin("For best results, change the 'Default Number of Torrents per Page' setting to the maximum in your profile on the TorrentLeech webpage."))
|
||||
: base("TorrentLeech",
|
||||
description: "This is what happens when you seed",
|
||||
link: "https://www.torrentleech.org/",
|
||||
caps: new TorznabCapabilities
|
||||
{
|
||||
SupportsImdbMovieSearch = true,
|
||||
SupportsImdbTVSearch = true
|
||||
},
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataRecaptchaLogin(
|
||||
"For best results, change the 'Default Number of Torrents per Page' setting to 100 in your Profile."))
|
||||
{
|
||||
Encoding = Encoding.UTF8;
|
||||
Language = "en-us";
|
||||
Type = "private";
|
||||
TorznabCaps.SupportsImdbMovieSearch = true;
|
||||
TorznabCaps.SupportsImdbTVSearch = true;
|
||||
|
||||
AddCategoryMapping(1, TorznabCatType.Movies, "Movies");
|
||||
AddCategoryMapping(8, TorznabCatType.MoviesSD, "Movies Cam");
|
||||
|
@ -121,12 +118,14 @@ namespace Jackett.Common.Indexers
|
|||
}
|
||||
else
|
||||
{
|
||||
var result = new ConfigurationDataBasicLogin();
|
||||
result.SiteLink.Value = configData.SiteLink.Value;
|
||||
result.Instructions.Value = configData.Instructions.Value;
|
||||
result.Username.Value = configData.Username.Value;
|
||||
result.Password.Value = configData.Password.Value;
|
||||
result.CookieHeader.Value = loginPage.Cookies;
|
||||
var result = new ConfigurationDataBasicLogin
|
||||
{
|
||||
SiteLink = {Value = configData.SiteLink.Value},
|
||||
Instructions = {Value = configData.Instructions.Value},
|
||||
Username = {Value = configData.Username.Value},
|
||||
Password = {Value = configData.Password.Value},
|
||||
CookieHeader = {Value = loginPage.Cookies}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -179,86 +178,68 @@ namespace Jackett.Common.Indexers
|
|||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.GetQueryString();
|
||||
searchString = Regex.Replace(searchString, @"(^|\s)-", " "); // remove dashes at the beginning of keywords as they exclude search strings (see issue #3096)
|
||||
var searchUrl = SearchUrl;
|
||||
var imdbId = ParseUtil.GetFullImdbID(query.ImdbID);
|
||||
|
||||
if (imdbId != null)
|
||||
{
|
||||
searchUrl += "imdbID/" + imdbId + "/";
|
||||
}
|
||||
// remove dashes at the beginning of keywords as they exclude search strings (see issue #3096)
|
||||
var searchString = query.GetQueryString();
|
||||
searchString = Regex.Replace(searchString, @"(^|\s)-", " ");
|
||||
|
||||
var searchUrl = SearchUrl;
|
||||
if (query.IsImdbQuery)
|
||||
searchUrl += "imdbID/" + query.ImdbID + "/";
|
||||
else if (!string.IsNullOrWhiteSpace(searchString))
|
||||
{
|
||||
searchUrl += "query/" + WebUtility.UrlEncode(searchString) + "/";
|
||||
}
|
||||
string.Format(SearchUrl, WebUtility.UrlEncode(searchString));
|
||||
|
||||
var cats = MapTorznabCapsToTrackers(query);
|
||||
if (cats.Count > 0)
|
||||
{
|
||||
searchUrl += "categories/";
|
||||
foreach (var cat in cats)
|
||||
{
|
||||
if (!searchUrl.EndsWith("/"))
|
||||
searchUrl += ",";
|
||||
searchUrl += cat;
|
||||
}
|
||||
}
|
||||
searchUrl += "categories/" + string.Join(",", cats);
|
||||
else
|
||||
{
|
||||
searchUrl += "newfilter/2"; // include 0day and music
|
||||
}
|
||||
|
||||
var results = await RequestStringWithCookiesAndRetry(searchUrl);
|
||||
|
||||
if (results.Content.Contains("/user/account/login"))
|
||||
if (results.Content.Contains("/user/account/login")) // re-login
|
||||
{
|
||||
//Cookie appears to expire after a period of time or logging in to the site via browser
|
||||
await DoLogin();
|
||||
results = await RequestStringWithCookiesAndRetry(searchUrl);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dynamic jsonObj = JsonConvert.DeserializeObject(results.Content);
|
||||
|
||||
foreach (var torrent in jsonObj.torrentList)
|
||||
var rows = (JArray)((JObject)JsonConvert.DeserializeObject(results.Content))["torrentList"];
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800; // 48 hours
|
||||
|
||||
release.Guid = new Uri(SiteLink + "torrent/" + torrent.fid);
|
||||
release.Comments = release.Guid;
|
||||
release.Title = torrent.name;
|
||||
|
||||
if (!query.MatchQueryStringAND(release.Title))
|
||||
var title = row["name"].ToString();
|
||||
if (!query.MatchQueryStringAND(title))
|
||||
continue;
|
||||
|
||||
release.Link = new Uri(SiteLink + "download/" + torrent.fid + "/" + torrent.filename);
|
||||
|
||||
release.PublishDate = DateTime.ParseExact(torrent.addedTimestamp.ToString(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
|
||||
|
||||
release.Size = (long)torrent.size;
|
||||
|
||||
release.Seeders = ParseUtil.CoerceInt(torrent.seeders.ToString());
|
||||
release.Peers = release.Seeders + ParseUtil.CoerceInt(torrent.leechers.ToString());
|
||||
|
||||
release.Category = MapTrackerCatToNewznab(torrent.categoryID.ToString());
|
||||
release.Description = torrent.categoryID.ToString();
|
||||
|
||||
release.Grabs = ParseUtil.CoerceInt(torrent.completed.ToString());
|
||||
|
||||
release.Imdb = ParseUtil.GetImdbID(torrent.imdbID.ToString());
|
||||
|
||||
release.UploadVolumeFactor = 1;
|
||||
var torrentId = row["fid"].ToString();
|
||||
var comments = new Uri(SiteLink + "torrent/" + torrentId);
|
||||
var link = new Uri(SiteLink + "download/" + torrentId + "/" + row["filename"]);
|
||||
var publishDate = DateTime.ParseExact(row["addedTimestamp"].ToString(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
|
||||
var seeders = (int)row["seeders"];
|
||||
|
||||
// freeleech #6579 #6624 #7367
|
||||
release.DownloadVolumeFactor = string.IsNullOrEmpty(torrent.download_multiplier.ToString()) ?
|
||||
1 :
|
||||
ParseUtil.CoerceInt(torrent.download_multiplier.ToString());
|
||||
var dlMultiplier = row["download_multiplier"].ToString();
|
||||
var dlVolumeFactor = string.IsNullOrEmpty(dlMultiplier) ? 1 : ParseUtil.CoerceInt(dlMultiplier);
|
||||
|
||||
var release = new ReleaseInfo
|
||||
{
|
||||
Title = title,
|
||||
Comments = comments,
|
||||
Guid = comments,
|
||||
Link = link,
|
||||
PublishDate = publishDate,
|
||||
Category = MapTrackerCatToNewznab(row["categoryID"].ToString()),
|
||||
Size = (long)row["size"],
|
||||
Grabs = (int)row["completed"],
|
||||
Seeders = seeders,
|
||||
Peers = seeders + (int)row["leechers"],
|
||||
Imdb = ParseUtil.GetImdbID(row["imdbID"].ToString()),
|
||||
UploadVolumeFactor = 1,
|
||||
DownloadVolumeFactor = dlVolumeFactor,
|
||||
MinimumRatio = 1,
|
||||
MinimumSeedTime = 172800 // 48 hours
|
||||
};
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue