New: Support for exclusive indexer flag

Co-authored-by: zakkarry <zak@ary.dev>
master
Bogdan 3 weeks ago committed by GitHub
parent 0f1d647cd7
commit 2d584f7eb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -26,15 +26,15 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
[SetUp]
public void Setup()
{
Subject.Definition = new IndexerDefinition()
Subject.Definition = new IndexerDefinition
{
Name = "HdBits",
Settings = new HDBitsSettings() { ApiKey = "fakekey" }
Settings = new HDBitsSettings { ApiKey = "fakekey" }
};
_movieSearchCriteria = new MovieSearchCriteria
{
Categories = new int[] { 2000, 2010 },
Categories = new[] { 2000, 2010 },
ImdbId = "0076759"
};
}
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests
var torrents = (await Subject.Fetch(_movieSearchCriteria)).Releases;
torrents.Should().HaveCount(2);
torrents.First().Should().BeOfType<HDBitsInfo>();
torrents.First().Should().BeOfType<TorrentInfo>();
var first = torrents.First() as TorrentInfo;

@ -55,7 +55,7 @@ namespace NzbDrone.Core.Indexers.Definitions
return FilterReleasesByQuery(cleanReleases, searchCriteria).ToList();
}
private IndexerCapabilities SetCapabilities()
private static IndexerCapabilities SetCapabilities()
{
var caps = new IndexerCapabilities
{
@ -69,7 +69,8 @@ namespace NzbDrone.Core.Indexers.Definitions
},
Flags = new List<IndexerFlag>
{
IndexerFlag.Internal
IndexerFlag.Internal,
IndexerFlag.Exclusive,
}
};
@ -275,13 +276,6 @@ namespace NzbDrone.Core.Indexers.Definitions
var details = row.InfoUrl;
var link = row.DownloadLink;
var flags = new HashSet<IndexerFlag>();
if (row.Internal)
{
flags.Add(IndexerFlag.Internal);
}
var release = new TorrentInfo
{
Title = row.Name,
@ -291,7 +285,7 @@ namespace NzbDrone.Core.Indexers.Definitions
Guid = details,
Categories = _categories.MapTrackerCatDescToNewznab(row.Category),
PublishDate = DateTime.Parse(row.CreatedAt, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal),
IndexerFlags = flags,
IndexerFlags = GetIndexerFlags(row),
Size = row.Size,
Grabs = row.Grabs,
Seeders = row.Seeders,
@ -319,6 +313,23 @@ namespace NzbDrone.Core.Indexers.Definitions
.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; }
}
@ -478,6 +489,8 @@ namespace NzbDrone.Core.Indexers.Definitions
public bool Limited { get; set; }
public bool Exclusive { get; set; }
public bool Internal { get; set; }
}
}

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits
return new HDBitsParser(Settings, Capabilities.Categories);
}
private IndexerCapabilities SetCapabilities()
private static IndexerCapabilities SetCapabilities()
{
var caps = new IndexerCapabilities
{
@ -43,6 +43,11 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits
MovieSearchParams = new List<MovieSearchParam>
{
MovieSearchParam.Q, MovieSearchParam.ImdbId
},
Flags = new List<IndexerFlag>
{
IndexerFlag.Internal,
IndexerFlag.Exclusive,
}
};

@ -85,6 +85,9 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits
[JsonProperty(PropertyName = "type_origin")]
public int TypeOrigin { get; set; }
[JsonProperty(PropertyName = "type_exclusive")]
public int TypeExclusive { get; set; }
[JsonProperty(PropertyName = "imdb")]
public ImdbInfo ImdbInfo { get; set; }

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

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

@ -63,6 +63,7 @@ namespace NzbDrone.Core.Indexers
}
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 NeutralLeech => new ("neutralleech", "Download and upload doesn't count toward ratio");
public static IndexerFlag HalfLeech => new ("halfleech", "Release counts 50% to ratio");

Loading…
Cancel
Save