mirror of
https://github.com/Jackett/Jackett
synced 2025-02-25 15:42:48 +00:00
parent
81e5589707
commit
7aac4fcfcb
1 changed files with 33 additions and 50 deletions
|
@ -28,19 +28,18 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
public TorrentBytes(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
||||
: base(name: "TorrentBytes",
|
||||
description: "A decade of torrentbytes",
|
||||
link: "https://www.torrentbytes.net/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataBasicLogin("For best results, change the 'Torrents per page' setting to 30 or greater (100 recommended) in your profile on the TorrentBytes webpage."))
|
||||
description: "A decade of torrentbytes",
|
||||
link: "https://www.torrentbytes.net/",
|
||||
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataBasicLogin("For best results, change the 'Torrents per page' setting to 30 or greater (100 recommended) in your profile on the TorrentBytes webpage."))
|
||||
{
|
||||
Encoding = Encoding.GetEncoding("iso-8859-1");
|
||||
Language = "en-us";
|
||||
Type = "private";
|
||||
|
||||
AddCategoryMapping(23, TorznabCatType.TVAnime, "Anime");
|
||||
AddCategoryMapping(52, TorznabCatType.PCMac, "Apple/All");
|
||||
AddCategoryMapping(22, TorznabCatType.PC, "Apps/misc");
|
||||
|
@ -80,24 +79,24 @@ namespace Jackett.Common.Indexers
|
|||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
LoadValuesFromJson(configJson);
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", configData.Username.Value },
|
||||
{ "password", configData.Password.Value },
|
||||
{ "returnto", "/" },
|
||||
{ "login", "Log in!" }
|
||||
};
|
||||
|
||||
var loginPage = await RequestStringWithCookies(SiteLink, string.Empty);
|
||||
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, SiteLink, SiteLink);
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("my.php"), () =>
|
||||
var pairs = new Dictionary<string, string>
|
||||
{
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(result.Content);
|
||||
var messageEl = dom.QuerySelector("td.embedded");
|
||||
var errorMessage = messageEl != null ? messageEl.TextContent : result.Content;
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
{"username", configData.Username.Value},
|
||||
{"password", configData.Password.Value},
|
||||
{"returnto", "/"},
|
||||
{"login", "Log in!"}
|
||||
};
|
||||
var loginPage = await RequestStringWithCookies(SiteLink, string.Empty);
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, SiteLink, SiteLink);
|
||||
await ConfigureIfOK(
|
||||
result.Cookies, result.Content?.Contains("my.php") == true, () =>
|
||||
{
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(result.Content);
|
||||
var messageEl = dom.QuerySelector("td.embedded");
|
||||
var errorMessage = messageEl != null ? messageEl.TextContent : result.Content;
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
|
@ -106,7 +105,6 @@ namespace Jackett.Common.Indexers
|
|||
var releases = new List<ReleaseInfo>();
|
||||
var searchString = query.GetQueryString();
|
||||
var searchUrl = BrowseUrl;
|
||||
var trackerCats = MapTorznabCapsToTrackers(query);
|
||||
var queryCollection = new NameValueCollection();
|
||||
|
||||
// Tracker can only search OR return things in categories
|
||||
|
@ -119,22 +117,12 @@ namespace Jackett.Common.Indexers
|
|||
else
|
||||
{
|
||||
foreach (var cat in MapTorznabCapsToTrackers(query))
|
||||
{
|
||||
queryCollection.Add("c" + cat, "1");
|
||||
}
|
||||
|
||||
queryCollection.Add("incldead", "0");
|
||||
}
|
||||
|
||||
searchUrl += "?" + queryCollection.GetQueryString();
|
||||
|
||||
await ProcessPage(releases, searchUrl);
|
||||
return releases;
|
||||
}
|
||||
|
||||
private async Task ProcessPage(List<ReleaseInfo> releases, string searchUrl)
|
||||
{
|
||||
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
|
||||
var response = await RequestStringWithCookiesAndRetry(searchUrl, referer: BrowseUrl);
|
||||
// On IP change the cookies become invalid, login again and retry
|
||||
if (response.IsRedirect)
|
||||
{
|
||||
|
@ -150,7 +138,6 @@ namespace Jackett.Common.Indexers
|
|||
foreach (var row in rows)
|
||||
{
|
||||
var release = new ReleaseInfo();
|
||||
|
||||
var link = row.QuerySelector("td:nth-of-type(2) a:nth-of-type(2)");
|
||||
release.Guid = new Uri(SiteLink + link.GetAttribute("href"));
|
||||
release.Comments = release.Guid;
|
||||
|
@ -158,8 +145,7 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
// There isn't a title attribute if the release name isn't truncated.
|
||||
if (string.IsNullOrWhiteSpace(release.Title))
|
||||
release.Title = link.FirstChild.ToString().Trim();
|
||||
|
||||
release.Title = link.FirstChild.TextContent.Trim();
|
||||
release.Description = release.Title;
|
||||
|
||||
// If we search an get no results, we still get a table just with no info.
|
||||
|
@ -176,26 +162,21 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
var qLink = row.QuerySelector("td:nth-of-type(2) a");
|
||||
release.Link = new Uri(SiteLink + qLink.GetAttribute("href"));
|
||||
|
||||
var added = row.QuerySelector("td:nth-of-type(5)").TextContent.Trim();
|
||||
release.PublishDate = DateTime.ParseExact(added, "yyyy-MM-ddHH:mm:ss", CultureInfo.InvariantCulture);
|
||||
|
||||
var sizeStr = row.QuerySelector("td:nth-of-type(7)").TextContent.Trim();
|
||||
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
||||
|
||||
release.Seeders = ParseUtil.CoerceInt(row.QuerySelector("td:nth-of-type(9)").TextContent.Trim());
|
||||
release.Peers = ParseUtil.CoerceInt(row.QuerySelector("td:nth-of-type(10)").TextContent.Trim()) + release.Seeders;
|
||||
|
||||
release.Peers = ParseUtil.CoerceInt(row.QuerySelector("td:nth-of-type(10)").TextContent.Trim()) +
|
||||
release.Seeders;
|
||||
var files = row.QuerySelector("td:nth-child(3)").TextContent;
|
||||
release.Files = ParseUtil.CoerceInt(files);
|
||||
|
||||
var grabs = row.QuerySelector("td:nth-child(8)").TextContent;
|
||||
if (grabs != "----")
|
||||
release.Grabs = ParseUtil.CoerceInt(grabs);
|
||||
|
||||
release.DownloadVolumeFactor = row.QuerySelector("font[color=\"green\"]:contains(\"F\"):contains(\"L\")") != null ? 0 : 1;
|
||||
release.DownloadVolumeFactor =
|
||||
row.QuerySelector("font[color=\"green\"]:contains(\"F\"):contains(\"L\")") != null ? 0 : 1;
|
||||
release.UploadVolumeFactor = 1;
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +184,8 @@ namespace Jackett.Common.Indexers
|
|||
{
|
||||
OnParseError(response.Content, ex);
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue