diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornApi.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornApi.cs index efb8230e4d..9d7c93ea84 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornApi.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornApi.cs @@ -21,6 +21,7 @@ public class Torrent public bool Scene { get; set; } public string Size { get; set; } public DateTime UploadTime { get; set; } + public string RemasterTitle { get; set; } public string Snatched { get; set; } public string Seeders { get; set; } public string Leechers { get; set; } diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs index fd3c43dcb1..d4337e73ec 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornParser.cs @@ -44,75 +44,61 @@ public IList ParseResponse(IndexerResponse indexerResponse) foreach (var torrent in result.Torrents) { var id = torrent.Id; + var title = torrent.ReleaseName; - if (_settings.GoldenOnly) - { - if (torrent.GoldenPopcorn) - { - torrentInfos.Add(new TorrentInfo() - { - Guid = string.Format("PassThePopcorn-{0}", id), - Title = torrent.ReleaseName, - Size = Int64.Parse(torrent.Size), - DownloadUrl = GetDownloadUrl(id, jsonResponse.AuthKey, jsonResponse.PassKey), - InfoUrl = GetInfoUrl(result.GroupId, id), - Seeders = Int32.Parse(torrent.Seeders), - Peers = Int32.Parse(torrent.Leechers) + Int32.Parse(torrent.Seeders), - PublishDate = torrent.UploadTime.ToUniversalTime(), - Golden = torrent.GoldenPopcorn, - Checked = torrent.Checked - }); - } - else - { - continue; - } - } + //if (IsPropertyExist(torrent, "RemasterTitle")) + //{ + // title = string.Format("{0] - {1}", title, torrent.RemasterTitle); + //} - if (_settings.CheckedOnly) - { - if (torrent.Checked) - { - torrentInfos.Add(new TorrentInfo() - { - Guid = string.Format("PassThePopcorn-{0}", id), - Title = torrent.ReleaseName, - Size = Int64.Parse(torrent.Size), - DownloadUrl = GetDownloadUrl(id, jsonResponse.AuthKey, jsonResponse.PassKey), - InfoUrl = GetInfoUrl(result.GroupId, id), - Seeders = Int32.Parse(torrent.Seeders), - Peers = Int32.Parse(torrent.Leechers) + Int32.Parse(torrent.Seeders), - PublishDate = torrent.UploadTime.ToUniversalTime(), - Golden = torrent.GoldenPopcorn, - Checked = torrent.Checked - }); - } - else - { - continue; - } - } - - if (!_settings.GoldenOnly && !_settings.CheckedOnly) + // Only add approved torrents + if (_settings.Approved && torrent.Checked) { torrentInfos.Add(new TorrentInfo() { Guid = string.Format("PassThePopcorn-{0}", id), - Title = torrent.ReleaseName, - Size = Int64.Parse(torrent.Size), + Title = title, + Size = long.Parse(torrent.Size), DownloadUrl = GetDownloadUrl(id, jsonResponse.AuthKey, jsonResponse.PassKey), InfoUrl = GetInfoUrl(result.GroupId, id), - Seeders = Int32.Parse(torrent.Seeders), - Peers = Int32.Parse(torrent.Leechers) + Int32.Parse(torrent.Seeders), + Seeders = int.Parse(torrent.Seeders), + Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), PublishDate = torrent.UploadTime.ToUniversalTime(), Golden = torrent.GoldenPopcorn, - Checked = torrent.Checked + Scene = torrent.Scene, + Approved = torrent.Checked }); } + // Add all torrents + else if (!_settings.Approved) + { + torrentInfos.Add(new TorrentInfo() + { + Guid = string.Format("PassThePopcorn-{0}", id), + Title = title, + Size = long.Parse(torrent.Size), + DownloadUrl = GetDownloadUrl(id, jsonResponse.AuthKey, jsonResponse.PassKey), + InfoUrl = GetInfoUrl(result.GroupId, id), + Seeders = int.Parse(torrent.Seeders), + Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), + PublishDate = torrent.UploadTime.ToUniversalTime(), + Golden = torrent.GoldenPopcorn, + Scene = torrent.Scene, + Approved = torrent.Checked + }); + } + // Don't add any torrents + else if (_settings.Approved && !torrent.Checked) + { + continue; + } } } - return torrentInfos.OrderBy(o => ((dynamic)o).Golden ? 0 : 1).ThenBy(o => ((dynamic)o).Checked ? 0 : 1).ThenBy(o => ((dynamic)o).PublishDate).ToArray(); + // prefer golden + // prefer scene + // require approval + return torrentInfos.OrderBy(o => ((dynamic)o).Golden ? 0 : 1).ThenBy(o => ((dynamic)o).Scene ? 0 : 1).ThenByDescending(o => ((dynamic)o).PublishDate).ToArray(); } private string GetDownloadUrl(int torrentId, string authKey, string passKey) @@ -135,7 +121,11 @@ private string GetInfoUrl(string groupId, int torrentId) .AddQueryParam("torrentid", torrentId); return url.FullUri; + } + public static bool IsPropertyExist(dynamic torrents, string name) + { + return torrents.GetType().GetProperty(name) != null; } } } diff --git a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs index 4a5ef10d77..88d7e15b2d 100644 --- a/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs +++ b/src/NzbDrone.Core/Indexers/PassThePopcorn/PassThePopcornSettings.cs @@ -35,11 +35,14 @@ public PassThePopcornSettings() [FieldDefinition(1, Label = "Cookie", HelpText = "PassThePopcorn uses a login cookie needed to access the API, you'll have to retrieve it via a browser.")] public string Cookie { get; set; } - [FieldDefinition(2, Type = FieldType.Checkbox, Label = "Only Golden", HelpText = "Only include golden torrents.")] - public bool GoldenOnly { get; set; } + [FieldDefinition(2, Type = FieldType.Checkbox, Label = "Prefer Golden", HelpText = "Favors Golden Popcorn-releases over all other releases.")] + public bool Golden { get; set; } - [FieldDefinition(3, Type = FieldType.Checkbox, Label = "Ony Staff Approved", HelpText = "Only include staff approved torrents.")] - public bool CheckedOnly { get; set; } + [FieldDefinition(3, Type = FieldType.Checkbox, Label = "Prefer Scene", HelpText = "Favors scene-releases over non-scene releases.")] + public bool Scene { get; set; } + + [FieldDefinition(4, Type = FieldType.Checkbox, Label = "Require Approved", HelpText = "Require staff-approval for releases to be accepted.")] + public bool Approved { get; set; } public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs b/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs index 8f4f49982d..94018f13e0 100644 --- a/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs @@ -12,7 +12,8 @@ public class TorrentInfo : ReleaseInfo // For PassThePopcorn public bool? Golden { get; set; } - public bool? Checked { get; set; } + public bool? Scene { get; set; } + public bool? Approved { get; set; } public static int? GetSeeders(ReleaseInfo release) {