New: Support for exclusive indexer flag

Co-authored-by: zakkarry <zak@ary.dev>
This commit is contained in:
Bogdan 2025-02-18 02:11:57 +02:00 committed by GitHub
parent 0f1d647cd7
commit 2d584f7eb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 58 additions and 37 deletions

View file

@ -26,15 +26,15 @@ public class HDBitsFixture : CoreTest<HDBits>
[SetUp] [SetUp]
public void Setup() public void Setup()
{ {
Subject.Definition = new IndexerDefinition() Subject.Definition = new IndexerDefinition
{ {
Name = "HdBits", Name = "HdBits",
Settings = new HDBitsSettings() { ApiKey = "fakekey" } Settings = new HDBitsSettings { ApiKey = "fakekey" }
}; };
_movieSearchCriteria = new MovieSearchCriteria _movieSearchCriteria = new MovieSearchCriteria
{ {
Categories = new int[] { 2000, 2010 }, Categories = new[] { 2000, 2010 },
ImdbId = "0076759" ImdbId = "0076759"
}; };
} }
@ -52,7 +52,7 @@ public async Task should_parse_recent_feed_from_HDBits(string fileName)
var torrents = (await Subject.Fetch(_movieSearchCriteria)).Releases; var torrents = (await Subject.Fetch(_movieSearchCriteria)).Releases;
torrents.Should().HaveCount(2); torrents.Should().HaveCount(2);
torrents.First().Should().BeOfType<HDBitsInfo>(); torrents.First().Should().BeOfType<TorrentInfo>();
var first = torrents.First() as TorrentInfo; var first = torrents.First() as TorrentInfo;

View file

@ -55,7 +55,7 @@ protected override IList<ReleaseInfo> CleanupReleases(IEnumerable<ReleaseInfo> r
return FilterReleasesByQuery(cleanReleases, searchCriteria).ToList(); return FilterReleasesByQuery(cleanReleases, searchCriteria).ToList();
} }
private IndexerCapabilities SetCapabilities() private static IndexerCapabilities SetCapabilities()
{ {
var caps = new IndexerCapabilities var caps = new IndexerCapabilities
{ {
@ -69,7 +69,8 @@ private IndexerCapabilities SetCapabilities()
}, },
Flags = new List<IndexerFlag> Flags = new List<IndexerFlag>
{ {
IndexerFlag.Internal IndexerFlag.Internal,
IndexerFlag.Exclusive,
} }
}; };
@ -275,13 +276,6 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
var details = row.InfoUrl; var details = row.InfoUrl;
var link = row.DownloadLink; var link = row.DownloadLink;
var flags = new HashSet<IndexerFlag>();
if (row.Internal)
{
flags.Add(IndexerFlag.Internal);
}
var release = new TorrentInfo var release = new TorrentInfo
{ {
Title = row.Name, Title = row.Name,
@ -291,7 +285,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
Guid = details, Guid = details,
Categories = _categories.MapTrackerCatDescToNewznab(row.Category), Categories = _categories.MapTrackerCatDescToNewznab(row.Category),
PublishDate = DateTime.Parse(row.CreatedAt, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal), PublishDate = DateTime.Parse(row.CreatedAt, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal),
IndexerFlags = flags, IndexerFlags = GetIndexerFlags(row),
Size = row.Size, Size = row.Size,
Grabs = row.Grabs, Grabs = row.Grabs,
Seeders = row.Seeders, Seeders = row.Seeders,
@ -319,6 +313,23 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
.ToArray(); .ToArray();
} }
private static HashSet<IndexerFlag> GetIndexerFlags(BeyondHDTorrent item)
{
var flags = new HashSet<IndexerFlag>();
if (item.Internal)
{
flags.Add(IndexerFlag.Internal);
}
if (item.Exclusive)
{
flags.Add(IndexerFlag.Exclusive);
}
return flags;
}
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; } public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
} }
@ -478,6 +489,8 @@ public class BeyondHDTorrent
public bool Limited { get; set; } public bool Limited { get; set; }
public bool Exclusive { get; set; }
public bool Internal { get; set; } public bool Internal { get; set; }
} }
} }

View file

@ -32,7 +32,7 @@ public override IParseIndexerResponse GetParser()
return new HDBitsParser(Settings, Capabilities.Categories); return new HDBitsParser(Settings, Capabilities.Categories);
} }
private IndexerCapabilities SetCapabilities() private static IndexerCapabilities SetCapabilities()
{ {
var caps = new IndexerCapabilities var caps = new IndexerCapabilities
{ {
@ -43,6 +43,11 @@ private IndexerCapabilities SetCapabilities()
MovieSearchParams = new List<MovieSearchParam> MovieSearchParams = new List<MovieSearchParam>
{ {
MovieSearchParam.Q, MovieSearchParam.ImdbId MovieSearchParam.Q, MovieSearchParam.ImdbId
},
Flags = new List<IndexerFlag>
{
IndexerFlag.Internal,
IndexerFlag.Exclusive,
} }
}; };

View file

@ -85,6 +85,9 @@ public class TorrentQueryResponse
[JsonProperty(PropertyName = "type_origin")] [JsonProperty(PropertyName = "type_origin")]
public int TypeOrigin { get; set; } public int TypeOrigin { get; set; }
[JsonProperty(PropertyName = "type_exclusive")]
public int TypeExclusive { get; set; }
[JsonProperty(PropertyName = "imdb")] [JsonProperty(PropertyName = "imdb")]
public ImdbInfo ImdbInfo { get; set; } public ImdbInfo ImdbInfo { get; set; }

View file

@ -1,9 +0,0 @@
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Definitions.HDBits
{
public class HDBitsInfo : TorrentInfo
{
public bool? Internal { get; set; }
}
}

View file

@ -62,16 +62,8 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
} }
var id = result.Id; var id = result.Id;
var internalRelease = result.TypeOrigin == 1;
var flags = new HashSet<IndexerFlag>(); releaseInfos.Add(new TorrentInfo
if (internalRelease)
{
flags.Add(IndexerFlag.Internal);
}
releaseInfos.Add(new HDBitsInfo
{ {
Guid = $"HDBits-{id}", Guid = $"HDBits-{id}",
Title = GetTitle(result), Title = GetTitle(result),
@ -85,21 +77,18 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
Files = (int)result.NumFiles, Files = (int)result.NumFiles,
Peers = result.Leechers + result.Seeders, Peers = result.Leechers + result.Seeders,
PublishDate = result.Added.ToUniversalTime(), PublishDate = result.Added.ToUniversalTime(),
Internal = internalRelease,
Year = result.ImdbInfo?.Year ?? 0, Year = result.ImdbInfo?.Year ?? 0,
ImdbId = result.ImdbInfo?.Id ?? 0, ImdbId = result.ImdbInfo?.Id ?? 0,
TvdbId = result.TvdbInfo?.Id ?? 0, TvdbId = result.TvdbInfo?.Id ?? 0,
DownloadVolumeFactor = GetDownloadVolumeFactor(result), DownloadVolumeFactor = GetDownloadVolumeFactor(result),
UploadVolumeFactor = GetUploadVolumeFactor(result), UploadVolumeFactor = GetUploadVolumeFactor(result),
IndexerFlags = flags IndexerFlags = GetIndexerFlags(result)
}); });
} }
return releaseInfos.ToArray(); return releaseInfos.ToArray();
} }
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
private string GetTitle(TorrentQueryResponse item) private string GetTitle(TorrentQueryResponse item)
{ {
// Use release name for XXX content and full discs // Use release name for XXX content and full discs
@ -108,6 +97,23 @@ private string GetTitle(TorrentQueryResponse item)
: item.Name; : item.Name;
} }
private static HashSet<IndexerFlag> GetIndexerFlags(TorrentQueryResponse item)
{
var flags = new HashSet<IndexerFlag>();
if (item.TypeOrigin == 1)
{
flags.Add(IndexerFlag.Internal);
}
if (item.TypeExclusive == 1)
{
flags.Add(IndexerFlag.Exclusive);
}
return flags;
}
private double GetDownloadVolumeFactor(TorrentQueryResponse item) private double GetDownloadVolumeFactor(TorrentQueryResponse item)
{ {
if (item.FreeLeech == "yes") if (item.FreeLeech == "yes")
@ -154,5 +160,7 @@ private string GetInfoUrl(string torrentId)
return url.FullUri; return url.FullUri;
} }
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
} }
} }

View file

@ -63,6 +63,7 @@ public override bool Equals(object obj)
} }
public static IndexerFlag Internal => new ("internal", "Uploader is an internal release group"); public static IndexerFlag Internal => new ("internal", "Uploader is an internal release group");
public static IndexerFlag Exclusive => new ("exclusive", "An exclusive release that must not be uploaded anywhere else");
public static IndexerFlag FreeLeech => new ("freeleech", "Download doesn't count toward ratio"); public static IndexerFlag FreeLeech => new ("freeleech", "Download doesn't count toward ratio");
public static IndexerFlag NeutralLeech => new ("neutralleech", "Download and upload doesn't count toward ratio"); public static IndexerFlag NeutralLeech => new ("neutralleech", "Download and upload doesn't count toward ratio");
public static IndexerFlag HalfLeech => new ("halfleech", "Release counts 50% to ratio"); public static IndexerFlag HalfLeech => new ("halfleech", "Release counts 50% to ratio");