From 99fd3a117bf2d15328f1fdf42cbfd0f8274c1ddf Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Tue, 12 Oct 2021 20:13:15 +0200 Subject: [PATCH] tvvault: add delay between requests and fix search & download (#12412) --- src/Jackett.Common/Indexers/TVVault.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Jackett.Common/Indexers/TVVault.cs b/src/Jackett.Common/Indexers/TVVault.cs index 7c24a1078..8f59a74f6 100644 --- a/src/Jackett.Common/Indexers/TVVault.cs +++ b/src/Jackett.Common/Indexers/TVVault.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Web; using AngleSharp.Html.Parser; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; @@ -55,6 +56,8 @@ namespace Jackett.Common.Indexers Language = "en-US"; Type = "private"; + webclient.requestDelay = 5.1; // 1 request per 5 seconds + AddCategoryMapping(1, TorznabCatType.TV); AddCategoryMapping(2, TorznabCatType.Movies); // as returned by TvCategoryParser.ParseTvShowQuality these two TV cats are required @@ -91,8 +94,6 @@ namespace Jackett.Common.Indexers var qc = new NameValueCollection { - { "order_by", "s3" }, - { "order_way", "DESC" }, { "disablegrouping", "1" } }; @@ -112,6 +113,14 @@ namespace Jackett.Common.Indexers var parser = new HtmlParser(); var doc = parser.ParseDocument(results.ContentString); + + // get params to build download link (user could be banned without those params) + var rssFeedUri = new Uri(SiteLink + doc.QuerySelector("link[href^=\"/feeds.php?feed=\"]") + .GetAttribute("href")); + var rssFeedQuery = HttpUtility.ParseQueryString(rssFeedUri.Query); + var downloadLinkExtraParams = "&authkey=" + rssFeedQuery["authkey"] + "&torrent_pass=" + rssFeedQuery["passkey"]; + + // parse rows var rows = doc.QuerySelectorAll("table.torrent_table > tbody > tr.torrent"); foreach (var row in rows) { @@ -125,7 +134,7 @@ namespace Jackett.Common.Indexers title += " " + description; var details = new Uri(SiteLink + qDetailsLink.GetAttribute("href")); var torrentId = qDetailsLink.GetAttribute("href").Split('=').Last(); - var link = new Uri(SiteLink + "torrents.php?action=download&id=" + torrentId); + var link = new Uri(SiteLink + "torrents.php?action=download&id=" + torrentId + downloadLinkExtraParams); var files = ParseUtil.CoerceLong(row.QuerySelector("td:nth-child(3)").TextContent); var publishDate = DateTimeUtil.FromTimeAgo(row.QuerySelector("td:nth-child(4)").TextContent);