immortalseed: category filtering and add sorting to skip sticky results (#13972)

Also check for Sitewide Free Torrent.
xspeeds: check for Sitewide Free Torrent.
This commit is contained in:
Bogdan 2023-02-05 04:30:20 +02:00 committed by GitHub
parent b55e053417
commit e0c6a3b469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 13 deletions

View File

@ -14,15 +14,15 @@ using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Newtonsoft.Json.Linq;
using NLog;
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
namespace Jackett.Common.Indexers
{
[ExcludeFromCodeCoverage]
public class ImmortalSeed : BaseWebIndexer
{
private string BrowsePage => SiteLink + "browse.php";
private string SearchUrl => SiteLink + "browse.php";
private string LoginUrl => SiteLink + "takelogin.php";
private string QueryString => "?do=search&keywords={0}&search_type=t_name&category=0&include_dead_torrents=no";
private readonly Regex _dateMatchRegex = new Regex(@"\d{4}-\d{2}-\d{2} \d{2}:\d{2} [AaPp][Mm]", RegexOptions.Compiled);
public override string[] LegacySiteLinks { get; protected set; } = {
@ -116,8 +116,35 @@ namespace Jackett.Common.Indexers
AddCategoryMapping(63, TorznabCatType.TVUHD, "TV Season Packs - 4K");
AddCategoryMapping(4, TorznabCatType.TVHD, "TV Season Packs - HD");
AddCategoryMapping(6, TorznabCatType.TVSD, "TV Season Packs - SD");
// Configure the sort selects
var sortBySelect = new SingleSelectConfigurationItem(
"Sort by",
new Dictionary<string, string>
{
{ "added", "created" },
{ "seeders", "seeders" },
{ "size", "size" },
{ "name", "title" }
})
{ Value = "added" };
configData.AddDynamic("sortrequestedfromsite", sortBySelect);
var orderSelect = new SingleSelectConfigurationItem(
"Order",
new Dictionary<string, string>
{
{ "desc", "descending" },
{ "asc", "ascending" }
})
{ Value = "desc" };
configData.AddDynamic("orderrequestedfromsite", orderSelect);
}
private string GetSortBy => ((SingleSelectConfigurationItem)configData.GetDynamic("sortrequestedfromsite")).Value;
private string GetOrder => ((SingleSelectConfigurationItem)configData.GetDynamic("orderrequestedfromsite")).Value;
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
LoadValuesFromJson(configJson);
@ -143,11 +170,28 @@ namespace Jackett.Common.Indexers
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchUrl = BrowsePage;
var searchParams = new Dictionary<string, string>
{
{ "category", "0" },
{ "include_dead_torrents", "yes" },
{ "sort", GetSortBy },
{ "order", GetOrder }
};
if (!string.IsNullOrWhiteSpace(query.GetQueryString()))
searchUrl += string.Format(QueryString, WebUtility.UrlEncode(query.GetQueryString()));
var searchString = Regex.Replace(query.GetQueryString(), @"[ -._]+", " ").Trim();
if (!string.IsNullOrWhiteSpace(searchString))
{
searchParams.Add("do", "search");
searchParams.Add("keywords", searchString);
searchParams.Add("search_type", "t_name");
}
var categoryMapping = MapTorznabCapsToTrackers(query);
if (categoryMapping.Any())
searchParams.Add("selectedcats2", string.Join(",", categoryMapping));
var searchUrl = $"{SearchUrl}?{searchParams.GetQueryString()}";
var results = await RequestWithCookiesAndRetryAsync(searchUrl);
@ -158,6 +202,8 @@ namespace Jackett.Common.Indexers
results = await RequestWithCookiesAndRetryAsync(searchUrl);
}
var releases = new List<ReleaseInfo>();
try
{
var parser = new HtmlParser();
@ -207,7 +253,7 @@ namespace Jackett.Common.Indexers
var cover = row.QuerySelector("td:nth-of-type(2) > div > img[src]")?.GetAttribute("src")?.Trim();
release.Poster = !string.IsNullOrEmpty(cover) && cover.StartsWith("/") ? new Uri(SiteLink + cover.TrimStart('/')) : null;
if (row.QuerySelector("img[title^=\"Free Torrent\"]") != null)
if (row.QuerySelector("img[title^=\"Free Torrent\"], img[title^=\"Sitewide Free Torrent\"]") != null)
release.DownloadVolumeFactor = 0;
else if (row.QuerySelector("img[title^=\"Silver Torrent\"]") != null)
release.DownloadVolumeFactor = 0.5;

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@ -325,17 +324,14 @@ namespace Jackett.Common.Indexers
var cover = row.QuerySelector("td:nth-of-type(2) > div > img[src]")?.GetAttribute("src")?.Trim();
release.Poster = !string.IsNullOrEmpty(cover) && cover.StartsWith("http") ? new Uri(cover) : null;
if (row.QuerySelector("img[alt^=\"Free Torrent\"]") != null)
if (row.QuerySelector("img[alt^=\"Free Torrent\"], img[alt^=\"Sitewide Free Torrent\"]") != null)
release.DownloadVolumeFactor = 0;
else if (row.QuerySelector("img[alt^=\"Silver Torrent\"]") != null)
release.DownloadVolumeFactor = 0.5;
else
release.DownloadVolumeFactor = 1;
if (row.QuerySelector("img[alt^=\"x2 Torrent\"]") != null)
release.UploadVolumeFactor = 2;
else
release.UploadVolumeFactor = 1;
release.UploadVolumeFactor = row.QuerySelector("img[alt^=\"x2 Torrent\"]") != null ? 2 : 1;
release.MinimumRatio = 0.8;