From a989bf82ea541151668f23c8e786c5b219b816eb Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 6 Apr 2024 00:08:32 +0300 Subject: [PATCH] Fixed: (Gazelle) Ignore ineligible releases with Use Freeleech Token --- .../Definitions/Gazelle/GazelleParser.cs | 20 +++++++++++++++---- .../Indexers/Definitions/GreatPosterWall.cs | 10 ++++++++-- .../Indexers/Definitions/Orpheus.cs | 18 ++++++++++++++--- .../Indexers/Definitions/Redacted.cs | 18 ++++++++++++++--- .../Indexers/Definitions/SecretCinema.cs | 8 ++++---- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs index 998ba835b..f24954d18 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs @@ -59,6 +59,12 @@ public class GazelleParser : IParseIndexerResponse { foreach (var torrent in result.Torrents) { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (Settings.UseFreeleechToken && !torrent.CanUseToken) + { + continue; + } + var id = torrent.TorrentId; var title = $"{result.Artist} - {result.GroupName} ({result.GroupYear}) [{torrent.Format} {torrent.Encoding}] [{torrent.Media}]"; @@ -72,14 +78,14 @@ public class GazelleParser : IParseIndexerResponse var release = new TorrentInfo { Guid = infoUrl, + InfoUrl = infoUrl, + DownloadUrl = GetDownloadUrl(id, !torrent.IsFreeLeech && !torrent.IsNeutralLeech && !torrent.IsPersonalFreeLeech), Title = WebUtility.HtmlDecode(title), Container = torrent.Encoding, Files = torrent.FileCount, Grabs = torrent.Snatches, Codec = torrent.Format, Size = long.Parse(torrent.Size), - DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken), - InfoUrl = infoUrl, Seeders = int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), PublishDate = torrent.Time.ToUniversalTime(), @@ -104,6 +110,12 @@ public class GazelleParser : IParseIndexerResponse } else { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (Settings.UseFreeleechToken && !result.CanUseToken) + { + continue; + } + var id = result.TorrentId; var groupName = WebUtility.HtmlDecode(result.GroupName); var infoUrl = GetInfoUrl(result.GroupId, id); @@ -111,10 +123,10 @@ public class GazelleParser : IParseIndexerResponse var release = new TorrentInfo { Guid = infoUrl, + InfoUrl = infoUrl, + DownloadUrl = GetDownloadUrl(id, !result.IsFreeLeech && !result.IsNeutralLeech && !result.IsPersonalFreeLeech), Title = groupName, Size = long.Parse(result.Size), - DownloadUrl = GetDownloadUrl(id, result.CanUseToken), - InfoUrl = infoUrl, Seeders = int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), Files = result.FileCount, diff --git a/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs b/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs index 931b2623e..765de7aa7 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs @@ -168,16 +168,22 @@ public class GreatPosterWallParser : GazelleParser { foreach (var torrent in result.Torrents) { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (_settings.UseFreeleechToken && !torrent.CanUseToken) + { + continue; + } + var infoUrl = GetInfoUrl(result.GroupId.ToString(), torrent.TorrentId); var time = DateTime.SpecifyKind(torrent.Time, DateTimeKind.Unspecified); var release = new TorrentInfo { - Title = WebUtility.HtmlDecode(torrent.FileName).Trim(), Guid = infoUrl, InfoUrl = infoUrl, + DownloadUrl = GetDownloadUrl(torrent.TorrentId, !torrent.IsFreeleech && !torrent.IsNeutralLeech && !torrent.IsPersonalFreeleech), + Title = WebUtility.HtmlDecode(torrent.FileName).Trim(), PosterUrl = GetPosterUrl(result.Cover), - DownloadUrl = GetDownloadUrl(torrent.TorrentId, torrent.CanUseToken), PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(8)).UtcDateTime, // Time is Chinese Time, add 8 hours difference from UTC Categories = ParseCategories(torrent), Size = torrent.Size, diff --git a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs index c5131907f..67f8ff55a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs @@ -276,6 +276,12 @@ namespace NzbDrone.Core.Indexers.Definitions { foreach (var torrent in result.Torrents) { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (_settings.UseFreeleechToken && !torrent.CanUseToken) + { + continue; + } + var id = torrent.TorrentId; var title = GetTitle(result, torrent); @@ -285,7 +291,7 @@ namespace NzbDrone.Core.Indexers.Definitions { Guid = infoUrl, InfoUrl = infoUrl, - DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken), + DownloadUrl = GetDownloadUrl(id, !torrent.IsFreeLeech && !torrent.IsNeutralLeech && !torrent.IsPersonalFreeLeech), Title = WebUtility.HtmlDecode(title), Artist = WebUtility.HtmlDecode(result.Artist), Album = WebUtility.HtmlDecode(result.GroupName), @@ -320,16 +326,22 @@ namespace NzbDrone.Core.Indexers.Definitions // Non-Audio files are formatted a little differently (1:1 for group and torrents) else { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (_settings.UseFreeleechToken && !result.CanUseToken) + { + continue; + } + var id = result.TorrentId; var infoUrl = GetInfoUrl(result.GroupId, id); var release = new TorrentInfo { Guid = infoUrl, + InfoUrl = infoUrl, + DownloadUrl = GetDownloadUrl(id, !result.IsFreeLeech && !result.IsNeutralLeech && !result.IsPersonalFreeLeech), Title = WebUtility.HtmlDecode(result.GroupName), Size = long.Parse(result.Size), - DownloadUrl = GetDownloadUrl(id, result.CanUseToken), - InfoUrl = infoUrl, Seeders = int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), PublishDate = long.TryParse(result.GroupTime, out var num) ? DateTimeOffset.FromUnixTimeSeconds(num).UtcDateTime : DateTimeUtil.FromFuzzyTime(result.GroupTime), diff --git a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs index 68133a087..2af30fb10 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs @@ -247,6 +247,12 @@ namespace NzbDrone.Core.Indexers.Definitions { foreach (var torrent in result.Torrents) { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (_settings.UseFreeleechToken && !torrent.CanUseToken) + { + continue; + } + // skip non-freeload results when freeload only is set if (_settings.FreeloadOnly && !torrent.IsFreeload) { @@ -262,7 +268,7 @@ namespace NzbDrone.Core.Indexers.Definitions { Guid = infoUrl, InfoUrl = infoUrl, - DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken && !torrent.IsFreeload), + DownloadUrl = GetDownloadUrl(id, !torrent.IsFreeLeech && !torrent.IsNeutralLeech && !torrent.IsFreeload && !torrent.IsPersonalFreeLeech), Title = WebUtility.HtmlDecode(title), Artist = WebUtility.HtmlDecode(result.Artist), Album = WebUtility.HtmlDecode(result.GroupName), @@ -297,6 +303,12 @@ namespace NzbDrone.Core.Indexers.Definitions // Non-Audio files are formatted a little differently (1:1 for group and torrents) else { + // skip releases that cannot be used with freeleech tokens when the option is enabled + if (_settings.UseFreeleechToken && !result.CanUseToken) + { + continue; + } + // skip non-freeload results when freeload only is set if (_settings.FreeloadOnly && !result.IsFreeload) { @@ -309,10 +321,10 @@ namespace NzbDrone.Core.Indexers.Definitions var release = new TorrentInfo { Guid = infoUrl, + InfoUrl = infoUrl, + DownloadUrl = GetDownloadUrl(id, !result.IsFreeLeech && !result.IsNeutralLeech && !result.IsFreeload && !result.IsPersonalFreeLeech), Title = WebUtility.HtmlDecode(result.GroupName), Size = long.Parse(result.Size), - DownloadUrl = GetDownloadUrl(id, result.CanUseToken && !result.IsFreeload), - InfoUrl = infoUrl, Seeders = int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), PublishDate = DateTimeOffset.FromUnixTimeSeconds(ParseUtil.CoerceLong(result.GroupTime)).UtcDateTime, diff --git a/src/NzbDrone.Core/Indexers/Definitions/SecretCinema.cs b/src/NzbDrone.Core/Indexers/Definitions/SecretCinema.cs index 53b688450..1daa4b4f8 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SecretCinema.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SecretCinema.cs @@ -113,14 +113,14 @@ public class SecretCinemaParser : IParseIndexerResponse var release = new TorrentInfo { Guid = $"SecretCinema-{id}", + InfoUrl = GetInfoUrl(result.GroupId, id), + DownloadUrl = GetDownloadUrl(id), Title = title, Container = torrent.Encoding, Files = torrent.FileCount, Grabs = torrent.Snatches, Codec = torrent.Format, Size = long.Parse(torrent.Size), - DownloadUrl = GetDownloadUrl(id), - InfoUrl = GetInfoUrl(result.GroupId, id), Seeders = int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(2)).UtcDateTime, @@ -173,10 +173,10 @@ public class SecretCinemaParser : IParseIndexerResponse var release = new TorrentInfo { Guid = $"SecretCinema-{id}", + InfoUrl = GetInfoUrl(result.GroupId, id), + DownloadUrl = GetDownloadUrl(id), Title = groupName, Size = long.Parse(result.Size), - DownloadUrl = GetDownloadUrl(id), - InfoUrl = GetInfoUrl(result.GroupId, id), Seeders = int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), Files = result.FileCount,