Fixed: (Gazelle) Ignore ineligible releases with Use Freeleech Token

pull/2096/head
Bogdan 9 months ago
parent ccc8d8002f
commit a989bf82ea

@ -59,6 +59,12 @@ public class GazelleParser : IParseIndexerResponse
{ {
foreach (var torrent in result.Torrents) 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 id = torrent.TorrentId;
var title = $"{result.Artist} - {result.GroupName} ({result.GroupYear}) [{torrent.Format} {torrent.Encoding}] [{torrent.Media}]"; 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 var release = new TorrentInfo
{ {
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl,
DownloadUrl = GetDownloadUrl(id, !torrent.IsFreeLeech && !torrent.IsNeutralLeech && !torrent.IsPersonalFreeLeech),
Title = WebUtility.HtmlDecode(title), Title = WebUtility.HtmlDecode(title),
Container = torrent.Encoding, Container = torrent.Encoding,
Files = torrent.FileCount, Files = torrent.FileCount,
Grabs = torrent.Snatches, Grabs = torrent.Snatches,
Codec = torrent.Format, Codec = torrent.Format,
Size = long.Parse(torrent.Size), Size = long.Parse(torrent.Size),
DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken),
InfoUrl = infoUrl,
Seeders = int.Parse(torrent.Seeders), Seeders = int.Parse(torrent.Seeders),
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
PublishDate = torrent.Time.ToUniversalTime(), PublishDate = torrent.Time.ToUniversalTime(),
@ -104,6 +110,12 @@ public class GazelleParser : IParseIndexerResponse
} }
else 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 id = result.TorrentId;
var groupName = WebUtility.HtmlDecode(result.GroupName); var groupName = WebUtility.HtmlDecode(result.GroupName);
var infoUrl = GetInfoUrl(result.GroupId, id); var infoUrl = GetInfoUrl(result.GroupId, id);
@ -111,10 +123,10 @@ public class GazelleParser : IParseIndexerResponse
var release = new TorrentInfo var release = new TorrentInfo
{ {
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl,
DownloadUrl = GetDownloadUrl(id, !result.IsFreeLeech && !result.IsNeutralLeech && !result.IsPersonalFreeLeech),
Title = groupName, Title = groupName,
Size = long.Parse(result.Size), Size = long.Parse(result.Size),
DownloadUrl = GetDownloadUrl(id, result.CanUseToken),
InfoUrl = infoUrl,
Seeders = int.Parse(result.Seeders), Seeders = int.Parse(result.Seeders),
Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders),
Files = result.FileCount, Files = result.FileCount,

@ -168,16 +168,22 @@ public class GreatPosterWallParser : GazelleParser
{ {
foreach (var torrent in result.Torrents) 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 infoUrl = GetInfoUrl(result.GroupId.ToString(), torrent.TorrentId);
var time = DateTime.SpecifyKind(torrent.Time, DateTimeKind.Unspecified); var time = DateTime.SpecifyKind(torrent.Time, DateTimeKind.Unspecified);
var release = new TorrentInfo var release = new TorrentInfo
{ {
Title = WebUtility.HtmlDecode(torrent.FileName).Trim(),
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl, InfoUrl = infoUrl,
DownloadUrl = GetDownloadUrl(torrent.TorrentId, !torrent.IsFreeleech && !torrent.IsNeutralLeech && !torrent.IsPersonalFreeleech),
Title = WebUtility.HtmlDecode(torrent.FileName).Trim(),
PosterUrl = GetPosterUrl(result.Cover), 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 PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(8)).UtcDateTime, // Time is Chinese Time, add 8 hours difference from UTC
Categories = ParseCategories(torrent), Categories = ParseCategories(torrent),
Size = torrent.Size, Size = torrent.Size,

@ -276,6 +276,12 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
foreach (var torrent in result.Torrents) 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 id = torrent.TorrentId;
var title = GetTitle(result, torrent); var title = GetTitle(result, torrent);
@ -285,7 +291,7 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl, InfoUrl = infoUrl,
DownloadUrl = GetDownloadUrl(id, torrent.CanUseToken), DownloadUrl = GetDownloadUrl(id, !torrent.IsFreeLeech && !torrent.IsNeutralLeech && !torrent.IsPersonalFreeLeech),
Title = WebUtility.HtmlDecode(title), Title = WebUtility.HtmlDecode(title),
Artist = WebUtility.HtmlDecode(result.Artist), Artist = WebUtility.HtmlDecode(result.Artist),
Album = WebUtility.HtmlDecode(result.GroupName), 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) // Non-Audio files are formatted a little differently (1:1 for group and torrents)
else 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 id = result.TorrentId;
var infoUrl = GetInfoUrl(result.GroupId, id); var infoUrl = GetInfoUrl(result.GroupId, id);
var release = new TorrentInfo var release = new TorrentInfo
{ {
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl,
DownloadUrl = GetDownloadUrl(id, !result.IsFreeLeech && !result.IsNeutralLeech && !result.IsPersonalFreeLeech),
Title = WebUtility.HtmlDecode(result.GroupName), Title = WebUtility.HtmlDecode(result.GroupName),
Size = long.Parse(result.Size), Size = long.Parse(result.Size),
DownloadUrl = GetDownloadUrl(id, result.CanUseToken),
InfoUrl = infoUrl,
Seeders = int.Parse(result.Seeders), Seeders = int.Parse(result.Seeders),
Peers = int.Parse(result.Leechers) + 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), PublishDate = long.TryParse(result.GroupTime, out var num) ? DateTimeOffset.FromUnixTimeSeconds(num).UtcDateTime : DateTimeUtil.FromFuzzyTime(result.GroupTime),

@ -247,6 +247,12 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
foreach (var torrent in result.Torrents) 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 // skip non-freeload results when freeload only is set
if (_settings.FreeloadOnly && !torrent.IsFreeload) if (_settings.FreeloadOnly && !torrent.IsFreeload)
{ {
@ -262,7 +268,7 @@ namespace NzbDrone.Core.Indexers.Definitions
{ {
Guid = infoUrl, Guid = infoUrl,
InfoUrl = 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), Title = WebUtility.HtmlDecode(title),
Artist = WebUtility.HtmlDecode(result.Artist), Artist = WebUtility.HtmlDecode(result.Artist),
Album = WebUtility.HtmlDecode(result.GroupName), 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) // Non-Audio files are formatted a little differently (1:1 for group and torrents)
else 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 // skip non-freeload results when freeload only is set
if (_settings.FreeloadOnly && !result.IsFreeload) if (_settings.FreeloadOnly && !result.IsFreeload)
{ {
@ -309,10 +321,10 @@ namespace NzbDrone.Core.Indexers.Definitions
var release = new TorrentInfo var release = new TorrentInfo
{ {
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl,
DownloadUrl = GetDownloadUrl(id, !result.IsFreeLeech && !result.IsNeutralLeech && !result.IsFreeload && !result.IsPersonalFreeLeech),
Title = WebUtility.HtmlDecode(result.GroupName), Title = WebUtility.HtmlDecode(result.GroupName),
Size = long.Parse(result.Size), Size = long.Parse(result.Size),
DownloadUrl = GetDownloadUrl(id, result.CanUseToken && !result.IsFreeload),
InfoUrl = infoUrl,
Seeders = int.Parse(result.Seeders), Seeders = int.Parse(result.Seeders),
Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders),
PublishDate = DateTimeOffset.FromUnixTimeSeconds(ParseUtil.CoerceLong(result.GroupTime)).UtcDateTime, PublishDate = DateTimeOffset.FromUnixTimeSeconds(ParseUtil.CoerceLong(result.GroupTime)).UtcDateTime,

@ -113,14 +113,14 @@ public class SecretCinemaParser : IParseIndexerResponse
var release = new TorrentInfo var release = new TorrentInfo
{ {
Guid = $"SecretCinema-{id}", Guid = $"SecretCinema-{id}",
InfoUrl = GetInfoUrl(result.GroupId, id),
DownloadUrl = GetDownloadUrl(id),
Title = title, Title = title,
Container = torrent.Encoding, Container = torrent.Encoding,
Files = torrent.FileCount, Files = torrent.FileCount,
Grabs = torrent.Snatches, Grabs = torrent.Snatches,
Codec = torrent.Format, Codec = torrent.Format,
Size = long.Parse(torrent.Size), Size = long.Parse(torrent.Size),
DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(result.GroupId, id),
Seeders = int.Parse(torrent.Seeders), Seeders = int.Parse(torrent.Seeders),
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(2)).UtcDateTime, PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(2)).UtcDateTime,
@ -173,10 +173,10 @@ public class SecretCinemaParser : IParseIndexerResponse
var release = new TorrentInfo var release = new TorrentInfo
{ {
Guid = $"SecretCinema-{id}", Guid = $"SecretCinema-{id}",
InfoUrl = GetInfoUrl(result.GroupId, id),
DownloadUrl = GetDownloadUrl(id),
Title = groupName, Title = groupName,
Size = long.Parse(result.Size), Size = long.Parse(result.Size),
DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(result.GroupId, id),
Seeders = int.Parse(result.Seeders), Seeders = int.Parse(result.Seeders),
Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders), Peers = int.Parse(result.Leechers) + int.Parse(result.Seeders),
Files = result.FileCount, Files = result.FileCount,

Loading…
Cancel
Save