Fixed: (GreatPosterWall) Parse categories based on resolution

pull/1386/head
Bogdan 2 years ago
parent e8dc5b3206
commit a51a8bf921

@ -104,6 +104,7 @@ public class GreatPosterWallRequestGenerator : GazelleRequestGenerator
public class GreatPosterWallParser : GazelleParser public class GreatPosterWallParser : GazelleParser
{ {
private readonly GreatPosterWallSettings _settings; private readonly GreatPosterWallSettings _settings;
private readonly HashSet<string> _hdResolutions = new () { "1080p", "1080i", "720p" };
public GreatPosterWallParser(GreatPosterWallSettings settings, IndexerCapabilities capabilities) public GreatPosterWallParser(GreatPosterWallSettings settings, IndexerCapabilities capabilities)
: base(settings, capabilities) : base(settings, capabilities)
@ -113,7 +114,7 @@ public class GreatPosterWallParser : GazelleParser
public override IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse) public override IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
{ {
var torrentInfos = new List<ReleaseInfo>(); var releaseInfos = new List<ReleaseInfo>();
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
{ {
@ -136,7 +137,7 @@ public class GreatPosterWallParser : GazelleParser
jsonResponse.Resource.Status.IsNullOrWhiteSpace() || jsonResponse.Resource.Status.IsNullOrWhiteSpace() ||
jsonResponse.Resource.Response == null) jsonResponse.Resource.Response == null)
{ {
return torrentInfos; return releaseInfos;
} }
foreach (var result in jsonResponse.Resource.Response.Results) foreach (var result in jsonResponse.Resource.Response.Results)
@ -148,15 +149,13 @@ public class GreatPosterWallParser : GazelleParser
var release = new GazelleInfo var release = new GazelleInfo
{ {
MinimumRatio = 1,
MinimumSeedTime = 172800,
Title = torrent.FileName, Title = torrent.FileName,
InfoUrl = infoUrl,
Guid = infoUrl, Guid = infoUrl,
InfoUrl = infoUrl,
PosterUrl = GetPosterUrl(result.Cover), PosterUrl = GetPosterUrl(result.Cover),
DownloadUrl = GetDownloadUrl(torrent.TorrentId, torrent.CanUseToken), 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 = new List<IndexerCategory> { NewznabStandardCategory.Movies }, Categories = ParseCategories(torrent),
Size = torrent.Size, Size = torrent.Size,
Seeders = torrent.Seeders, Seeders = torrent.Seeders,
Peers = torrent.Seeders + torrent.Leechers, Peers = torrent.Seeders + torrent.Leechers,
@ -164,11 +163,12 @@ public class GreatPosterWallParser : GazelleParser
Files = torrent.FileCount, Files = torrent.FileCount,
Scene = torrent.Scene, Scene = torrent.Scene,
DownloadVolumeFactor = torrent.IsFreeleech || torrent.IsNeutralLeech || torrent.IsPersonalFreeleech ? 0 : 1, DownloadVolumeFactor = torrent.IsFreeleech || torrent.IsNeutralLeech || torrent.IsPersonalFreeleech ? 0 : 1,
UploadVolumeFactor = torrent.IsNeutralLeech ? 0 : 1 UploadVolumeFactor = torrent.IsNeutralLeech ? 0 : 1,
MinimumRatio = 1,
MinimumSeedTime = 172800 // 48 hours
}; };
var imdbId = ParseUtil.GetImdbID(result.ImdbId); var imdbId = ParseUtil.GetImdbID(result.ImdbId);
if (imdbId != null) if (imdbId != null)
{ {
release.ImdbId = (int)imdbId; release.ImdbId = (int)imdbId;
@ -194,11 +194,11 @@ public class GreatPosterWallParser : GazelleParser
break; break;
} }
torrentInfos.Add(release); releaseInfos.Add(release);
} }
} }
return torrentInfos return releaseInfos
.OrderByDescending(o => o.PublishDate) .OrderByDescending(o => o.PublishDate)
.ToArray(); .ToArray();
} }
@ -213,6 +213,22 @@ public class GreatPosterWallParser : GazelleParser
return url.FullUri; return url.FullUri;
} }
private List<IndexerCategory> ParseCategories(GreatPosterWallTorrent torrent)
{
var cats = new List<IndexerCategory>
{
NewznabStandardCategory.Movies,
torrent.Resolution switch
{
var res when _hdResolutions.Contains(res) => NewznabStandardCategory.MoviesHD,
"2160p" => NewznabStandardCategory.MoviesUHD,
_ => NewznabStandardCategory.MoviesSD
}
};
return cats;
}
} }
public class GreatPosterWallSettings : GazelleSettings public class GreatPosterWallSettings : GazelleSettings

Loading…
Cancel
Save