From d1e8e20c41658f7d22bc38a9a5d4bb9a6d6577e5 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 13 Sep 2023 12:45:59 +0300 Subject: [PATCH] subsplease: update category mappings for movie releases Co-authored-by: Lemres <45440100+Calemy@users.noreply.github.com> --- src/Jackett.Common/Indexers/SubsPlease.cs | 35 ++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Jackett.Common/Indexers/SubsPlease.cs b/src/Jackett.Common/Indexers/SubsPlease.cs index 907303b85..7350f7e3e 100644 --- a/src/Jackett.Common/Indexers/SubsPlease.cs +++ b/src/Jackett.Common/Indexers/SubsPlease.cs @@ -66,11 +66,15 @@ namespace Jackett.Common.Indexers TvSearchParams = new List { TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep + }, + MovieSearchParams = new List + { + MovieSearchParam.Q } }; - // Configure the category mappings - caps.Categories.AddCategoryMapping(1, TorznabCatType.TVAnime, "Anime"); + caps.Categories.AddCategoryMapping(1, TorznabCatType.TVAnime); + caps.Categories.AddCategoryMapping(2, TorznabCatType.MoviesOther); return caps; } @@ -142,12 +146,16 @@ namespace Jackett.Common.Indexers // When there are no results, the API returns an empty array or empty response instead of an object if (string.IsNullOrWhiteSpace(json) || json == "[]") + { return releaseInfo; + } var releases = JsonConvert.DeserializeObject>(json); + foreach (var keyValue in releases) { - Release r = keyValue.Value; + var r = keyValue.Value; + var baseRelease = new ReleaseInfo { Details = new Uri(SiteLink + $"shows/{r.Page}/"), @@ -161,6 +169,12 @@ namespace Jackett.Common.Indexers DownloadVolumeFactor = 0, UploadVolumeFactor = 1 }; + + if (r.Episode.ToLowerInvariant() == "movie") + { + baseRelease.Category.Add(TorznabCatType.MoviesOther.ID); + } + foreach (var d in r.Downloads) { var release = (ReleaseInfo)baseRelease.Clone(); @@ -169,21 +183,34 @@ namespace Jackett.Common.Indexers release.MagnetUri = new Uri(d.Magnet); release.Link = null; release.Guid = new Uri(d.Magnet); - Match sizeMatch = Regex.Match(d.Magnet, "&xl=\\d+"); + + var sizeMatch = Regex.Match(d.Magnet, "&xl=\\d+"); + if (sizeMatch.Success) + { release.Size = ParseUtil.CoerceLong(sizeMatch.Value.Replace("&xl=", string.Empty)); + } else { // The API doesn't tell us file size, so give an estimate based on resolution if (string.Equals(d.Res, "1080")) + { release.Size = 1395864371; // 1.3GB + } else if (string.Equals(d.Res, "720")) + { release.Size = 734003200; // 700MB + } else if (string.Equals(d.Res, "480")) + { release.Size = 367001600; // 350MB + } else + { release.Size = 1073741824; // 1GB + } } + releaseInfo.Add(release); } }