New: Rewrite Indexer Flags Implementation

This commit is contained in:
Qstick
2021-05-21 00:25:46 -04:00
parent cebdcd6065
commit dd66d7845c
18 changed files with 127 additions and 142 deletions
@@ -51,7 +51,11 @@ namespace NzbDrone.Core.Indexers.FileList
BookSearchParams = new List<BookSearchParam>
{
BookSearchParam.Q
}
},
Flags = new List<IndexerFlag>
{
IndexerFlag.FreeLeech
}
};
caps.Categories.AddCategoryMapping(1, NewznabStandardCategory.MoviesSD, "Filme SD");
@@ -36,11 +36,11 @@ namespace NzbDrone.Core.Indexers.FileList
{
var id = result.Id;
IndexerFlags flags = 0;
var flags = new List<IndexerFlag>();
if (result.FreeLeech)
{
flags |= IndexerFlags.G_Freeleech;
flags.Add(IndexerFlag.FreeLeech);
}
var imdbId = 0;
@@ -55,16 +55,16 @@ namespace NzbDrone.Core.Indexers.HDBits
var id = result.Id;
var internalRelease = result.TypeOrigin == 1 ? true : false;
IndexerFlags flags = 0;
var flags = new List<IndexerFlag>();
if (result.FreeLeech == "yes")
{
flags |= IndexerFlags.G_Freeleech;
flags.Add(IndexerFlag.FreeLeech);
}
if (internalRelease)
{
flags |= IndexerFlags.HDB_Internal;
flags.Add(IndexerFlag.Internal);
}
torrentInfos.Add(new HDBitsInfo()
@@ -52,6 +52,12 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
MovieSearchParams = new List<MovieSearchParam>
{
MovieSearchParam.Q, MovieSearchParam.ImdbId
},
Flags = new List<IndexerFlag>
{
IndexerFlag.FreeLeech,
PassThePopcornFlag.Golden,
PassThePopcornFlag.Approved
}
};
@@ -74,7 +80,13 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
public override IParseIndexerResponse GetParser()
{
return new PassThePopcornParser(BaseUrl, _logger);
return new PassThePopcornParser(BaseUrl, Capabilities, _logger);
}
}
public class PassThePopcornFlag : IndexerFlag
{
public static IndexerFlag Golden => new IndexerFlag("golden", "Release follows Golden Popcorn quality rules");
public static IndexerFlag Approved => new IndexerFlag("approved", "Release approved by PTP");
}
}
@@ -13,10 +13,12 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
public class PassThePopcornParser : IParseIndexerResponse
{
private readonly string _baseUrl;
private readonly IndexerCapabilities _capabilities;
private readonly Logger _logger;
public PassThePopcornParser(string baseUrl, Logger logger)
public PassThePopcornParser(string baseUrl, IndexerCapabilities capabilities, Logger logger)
{
_baseUrl = baseUrl;
_capabilities = capabilities;
_logger = logger;
}
@@ -63,26 +65,27 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn
{
var id = torrent.Id;
var title = torrent.ReleaseName;
IndexerFlags flags = 0;
var flags = new List<IndexerFlag>();
if (torrent.GoldenPopcorn)
{
flags |= IndexerFlags.PTP_Golden; //title = $"{title} 🍿";
flags.Add(PassThePopcornFlag.Golden);
}
if (torrent.Checked)
{
flags |= IndexerFlags.PTP_Approved; //title = $"{title} ✔";
flags.Add(PassThePopcornFlag.Approved); //title = $"{title} ✔";
}
if (torrent.FreeleechType == "Freeleech")
{
flags |= IndexerFlags.G_Freeleech;
flags.Add(IndexerFlag.FreeLeech);
}
if (torrent.Scene)
{
flags |= IndexerFlags.G_Scene;
flags.Add(IndexerFlag.Scene);
}
var free = !(torrent.FreeleechType is null);
@@ -173,9 +173,9 @@ namespace NzbDrone.Core.Indexers.Torznab
return base.GetPeers(item);
}
protected IndexerFlags GetFlags(XElement item)
protected List<IndexerFlag> GetFlags(XElement item)
{
IndexerFlags flags = 0;
var flags = new List<IndexerFlag>();
var downloadFactor = TryGetFloatTorznabAttribute(item, "downloadvolumefactor", 1);
@@ -183,17 +183,17 @@ namespace NzbDrone.Core.Indexers.Torznab
if (uploadFactor == 2)
{
flags |= IndexerFlags.G_DoubleUpload;
flags.Add(IndexerFlag.DoubleUpload);
}
if (downloadFactor == 0.5)
{
flags |= IndexerFlags.G_Halfleech;
flags.Add(IndexerFlag.HalfLeech);
}
if (downloadFactor == 0.0)
{
flags |= IndexerFlags.G_Freeleech;
flags.Add(IndexerFlag.FreeLeech);
}
return flags;