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
@@ -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);