From e304461dfb242544e741be81253572a82b9e6632 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 18 Jul 2021 21:33:17 -0400 Subject: [PATCH] New: Add PosterUrl to ReleaseInfo for parsing --- .../Indexers/Definitions/Anthelion.cs | 3 ++- .../Definitions/Cardigann/CardigannParser.cs | 18 +++++++++--------- .../Indexers/Definitions/DanishBytes.cs | 1 + .../Indexers/Definitions/HDTorrents.cs | 3 ++- .../Indexers/Definitions/Nebulance.cs | 1 + .../Indexers/Definitions/SpeedApp.cs | 1 + .../Indexers/Definitions/SuperBits.cs | 11 ++++++----- src/NzbDrone.Core/Indexers/Definitions/YTS.cs | 2 +- .../Indexers/Definitions/ZonaQ.cs | 1 + src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs | 2 ++ src/Prowlarr.Api.V1/Search/SearchResource.cs | 3 +++ 11 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs b/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs index 8021a3986..6b4178183 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs @@ -238,7 +238,7 @@ namespace NzbDrone.Core.Indexers.Definitions var torrentId = qDetailsLink.GetAttribute("href").Split('=').Last(); var link = _settings.BaseUrl + "torrents.php?action=download&id=" + torrentId; var posterStr = qDetailsLink.GetAttribute("data-cover"); - var poster = !string.IsNullOrWhiteSpace(posterStr) ? new Uri(qDetailsLink.GetAttribute("data-cover")) : null; + var poster = !string.IsNullOrWhiteSpace(posterStr) ? posterStr : null; var files = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(3)").TextContent); var publishDate = DateTimeUtil.FromTimeAgo(row.QuerySelector("td:nth-child(4)").TextContent); @@ -276,6 +276,7 @@ namespace NzbDrone.Core.Indexers.Definitions Categories = category, DownloadUrl = link, InfoUrl = details, + PosterUrl = poster, Guid = link, ImdbId = imdb.GetValueOrDefault(), Seeders = seeders, diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs index 4c0494d51..57d4e469f 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs @@ -293,6 +293,15 @@ namespace NzbDrone.Core.Indexers.Cardigann release.TvdbId = (int)ParseUtil.CoerceLong(tvdbId); value = release.TvdbId.ToString(); break; + case "poster": + if (!string.IsNullOrWhiteSpace(value)) + { + var poster = ResolvePath(value, searchUrlUri); + release.PosterUrl = poster.AbsoluteUri; + } + + value = release.PosterUrl; + break; //case "author": // release.Author = value; @@ -300,15 +309,6 @@ namespace NzbDrone.Core.Indexers.Cardigann //case "booktitle": // release.BookTitle = value; // break; - //case "banner": - // if (!string.IsNullOrWhiteSpace(value)) - // { - // var bannerurl = ResolvePath(value, searchUrlUri); - // release.BannerUrl = bannerurl; - // } - - // value = release.BannerUrl.ToString(); - // break; default: break; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/DanishBytes.cs b/src/NzbDrone.Core/Indexers/Definitions/DanishBytes.cs index 447ebe07a..a0955fe7c 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/DanishBytes.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/DanishBytes.cs @@ -205,6 +205,7 @@ namespace NzbDrone.Core.Indexers.Definitions Title = row.Name, InfoUrl = $"{_settings.BaseUrl}torrents/{row.Id}", DownloadUrl = $"{_settings.BaseUrl}torrent/download/{row.Id}.{jsonResponse.Resource.Rsskey}", + PosterUrl = row.PosterImage, PublishDate = row.CreatedAt, Categories = _categories.MapTrackerCatToNewznab(row.CategoryId), Size = row.Size, diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs index 9d44306f7..c15401f91 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs @@ -255,7 +255,7 @@ namespace NzbDrone.Core.Indexers.Definitions var details = new Uri(_settings.BaseUrl + mainLink.GetAttribute("href")); var posterMatch = _posterRegex.Match(mainLink.GetAttribute("onmouseover")); - var poster = posterMatch.Success ? new Uri(_settings.BaseUrl + posterMatch.Groups[1].Value.Replace("\\", "/")) : null; + var poster = posterMatch.Success ? _settings.BaseUrl + posterMatch.Groups[1].Value.Replace("\\", "/") : null; var link = new Uri(_settings.BaseUrl + row.Children[4].FirstElementChild.GetAttribute("href")); var description = row.Children[2].QuerySelector("span").TextContent; @@ -331,6 +331,7 @@ namespace NzbDrone.Core.Indexers.Definitions Guid = details.AbsoluteUri, DownloadUrl = link.AbsoluteUri, InfoUrl = details.AbsoluteUri, + PosterUrl = poster, PublishDate = publishDate, Categories = cat, ImdbId = imdb ?? 0, diff --git a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs index 64c4599dd..901175f5d 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs @@ -242,6 +242,7 @@ namespace NzbDrone.Core.Indexers.Definitions Title = title, Guid = details, InfoUrl = details, + PosterUrl = poster.AbsoluteUri, DownloadUrl = link, Categories = new List { TvCategoryFromQualityParser.ParseTvShowQuality(title) }, Size = size, diff --git a/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs b/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs index 834bb67ca..5ef0518ca 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs @@ -378,6 +378,7 @@ namespace NzbDrone.Core.Indexers.Definitions Size = torrent.Size, ImdbId = ParseUtil.GetImdbID(torrent.ImdbId).GetValueOrDefault(), DownloadUrl = $"{Settings.BaseUrl}/api/torrent/{torrent.Id}/download", + PosterUrl = torrent.Poster, InfoUrl = torrent.Url, Grabs = torrent.TimesCompleted, PublishDate = torrent.CreatedAt, diff --git a/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs b/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs index 863a45d00..dc92cf62a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs @@ -252,10 +252,11 @@ namespace NzbDrone.Core.Indexers.Definitions release.UploadVolumeFactor = 1; - //if (!string.IsNullOrWhiteSpace(row.customcover.ToString())) - //{ - // release.Poster = new Uri(SiteLink + row.customcover); - //} + if (!string.IsNullOrWhiteSpace(row.customcover.ToString())) + { + release.PosterUrl = _settings.BaseUrl + row.customcover; + } + if (row.imdbid2 != null && row.imdbid2.ToString().StartsWith("tt")) { release.ImdbId = ParseUtil.CoerceInt(row.imdbid2.ToString().Substring(2)); @@ -267,7 +268,7 @@ namespace NzbDrone.Core.Indexers.Definitions descriptions.Add("Rating: " + row.rating); descriptions.Add("Plot: " + row.plot); - //release.Poster = new Uri(SiteLink + "img/imdb/" + row.imdbid2 + ".jpg"); + release.PosterUrl = _settings.BaseUrl + "img/imdb/" + row.imdbid2 + ".jpg"; } if ((int)row.p2p == 1) diff --git a/src/NzbDrone.Core/Indexers/Definitions/YTS.cs b/src/NzbDrone.Core/Indexers/Definitions/YTS.cs index c2c600dfb..d98ee986e 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/YTS.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/YTS.cs @@ -247,7 +247,7 @@ namespace NzbDrone.Core.Indexers.Definitions release.InfoUrl = movie.Value("url"); - //release.Poster = new Uri(movie.Value("large_cover_image")); + release.PosterUrl = new Uri(movie.Value("large_cover_image")).AbsoluteUri; release.Guid = release.DownloadUrl; // map the quality to a newznab category for torznab compatibility (for Radarr, etc) diff --git a/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs b/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs index fe2c6ea77..1b07f4a4b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs @@ -375,6 +375,7 @@ namespace NzbDrone.Core.Indexers.Definitions InfoUrl = details.AbsoluteUri, Guid = details.AbsoluteUri, DownloadUrl = link.AbsoluteUri, + PosterUrl = poster.AbsoluteUri, PublishDate = publishDate, Categories = cat, Size = size, diff --git a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs index e4aa5286e..3642dc7e6 100644 --- a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs @@ -33,6 +33,8 @@ namespace NzbDrone.Core.Parser.Model public int TmdbId { get; set; } public DateTime PublishDate { get; set; } + public string PosterUrl { get; set; } + public string Origin { get; set; } public string Source { get; set; } public string Container { get; set; } diff --git a/src/Prowlarr.Api.V1/Search/SearchResource.cs b/src/Prowlarr.Api.V1/Search/SearchResource.cs index 8aab4f237..15ddf9f08 100644 --- a/src/Prowlarr.Api.V1/Search/SearchResource.cs +++ b/src/Prowlarr.Api.V1/Search/SearchResource.cs @@ -27,6 +27,7 @@ namespace Prowlarr.Api.V1.Search public string CommentUrl { get; set; } public string DownloadUrl { get; set; } public string InfoUrl { get; set; } + public string PosterUrl { get; set; } public IEnumerable IndexerFlags { get; set; } public ICollection Categories { get; set; } @@ -65,6 +66,7 @@ namespace Prowlarr.Api.V1.Search CommentUrl = releaseInfo.CommentUrl, DownloadUrl = releaseInfo.DownloadUrl, InfoUrl = releaseInfo.InfoUrl, + PosterUrl = releaseInfo.PosterUrl, Categories = releaseInfo.Categories, //ReleaseWeight @@ -101,6 +103,7 @@ namespace Prowlarr.Api.V1.Search model.Size = resource.Size; model.DownloadUrl = resource.DownloadUrl; model.InfoUrl = resource.InfoUrl; + model.PosterUrl = resource.PosterUrl; model.CommentUrl = resource.CommentUrl; model.IndexerId = resource.IndexerId; model.Indexer = resource.Indexer;