From 6fa840a70a223bac17eb583c2ebd4b752d81a035 Mon Sep 17 00:00:00 2001 From: Garfield69 Date: Sun, 10 Nov 2024 16:57:06 +1300 Subject: [PATCH] xspeeds: fix for #15700 --- .../Indexers/Definitions/XSpeeds.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Jackett.Common/Indexers/Definitions/XSpeeds.cs b/src/Jackett.Common/Indexers/Definitions/XSpeeds.cs index 3c4fb1015..b001a6f26 100644 --- a/src/Jackett.Common/Indexers/Definitions/XSpeeds.cs +++ b/src/Jackett.Common/Indexers/Definitions/XSpeeds.cs @@ -224,13 +224,13 @@ namespace Jackett.Common.Indexers.Definitions protected override async Task> PerformQuery(TorznabQuery query) { var prevCook = CookieHeader + ""; - var categoryMapping = MapTorznabCapsToTrackers(query).Distinct().ToList(); + var queryCat = categoryMapping.FirstIfSingleOrDefault("0"); var searchParams = new Dictionary { { "do", "search" }, - { "category", categoryMapping.FirstIfSingleOrDefault("0") }, // multi category search not supported + { "category", queryCat }, // multi category search not supported { "include_dead_torrents", "yes" } }; @@ -310,10 +310,18 @@ namespace Jackett.Common.Indexers.Definitions var qPoster = row.QuerySelector("td:nth-of-type(2) .tooltip-content img"); if (qPoster != null) release.Poster = new Uri(qPoster.GetAttribute("src")); - - var categoryLink = row.QuerySelector("td:nth-of-type(1) a").GetAttribute("href"); - var cat = ParseUtil.GetArgumentFromQueryString(categoryLink, "category"); - release.Category = MapTrackerCatToNewznab(cat); + // for keywordless searches with a category query return the category query instead of the row category + // to prevent no results + if (string.IsNullOrWhiteSpace(searchString) && !queryCat.Equals("0")) + { + release.Category = MapTrackerCatToNewznab(queryCat); + } + else + { + var categoryLink = row.QuerySelector("td:nth-of-type(1) a").GetAttribute("href"); + var cat = ParseUtil.GetArgumentFromQueryString(categoryLink, "category"); + release.Category = MapTrackerCatToNewznab(cat); + } var grabs = row.QuerySelector("td:nth-child(6)").TextContent; release.Grabs = ParseUtil.CoerceInt(grabs);