From 57dac6afdde69757a7cd88532844aa61e226b463 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 5 Jan 2023 18:17:20 +0200 Subject: [PATCH] Fixed: (GreatPosterWall) Use UTC for PublishDate, order releases and map categories accordingly --- .../Indexers/Definitions/GreatPosterWall.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs b/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs index 5866a8e18..f8a161f48 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/GreatPosterWall.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net; using Newtonsoft.Json; using NLog; @@ -80,6 +81,8 @@ public class GreatPosterWallRequestGenerator : GazelleRequestGenerator public class GreatPosterWallParser : GazelleParser { + private readonly HashSet _hdResolutions = new HashSet { "1080p", "1080i", "720p" }; + public GreatPosterWallParser(GazelleSettings settings, IndexerCapabilities capabilities) : base(settings, capabilities) { @@ -130,8 +133,8 @@ public class GreatPosterWallParser : GazelleParser Guid = infoUrl, PosterUrl = GetPosterUrl(result.Cover), DownloadUrl = GetDownloadUrl(torrent.TorrentId, torrent.CanUseToken), - PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(8)).LocalDateTime, // Time is Chinese Time, add 8 hours difference from UTC and then convert back to local time - Categories = new List { NewznabStandardCategory.Movies }, + PublishDate = new DateTimeOffset(time, TimeSpan.FromHours(8)).UtcDateTime, // Time is Chinese Time, add 8 hours difference from UTC + Categories = ParseCategories(torrent), Size = torrent.Size, Seeders = torrent.Seeders, Peers = torrent.Seeders + torrent.Leechers, @@ -173,7 +176,9 @@ public class GreatPosterWallParser : GazelleParser } } - return torrentInfos; + return torrentInfos + .OrderByDescending(o => o.PublishDate) + .ToArray(); } protected string GetDownloadUrl(int torrentId, bool canUseToken) @@ -186,6 +191,20 @@ public class GreatPosterWallParser : GazelleParser return url.FullUri; } + + protected virtual List ParseCategories(GreatPosterWallTorrent torrent) + { + var cats = new List(); + + cats.Add(torrent.Resolution switch + { + var res when _hdResolutions.Contains(res) => NewznabStandardCategory.MoviesHD, + "2160p" => NewznabStandardCategory.MoviesUHD, + _ => NewznabStandardCategory.MoviesSD + }); + + return cats; + } } public class GreatPosterWallResponse