From 09e81da34c163b6634828a10eb213a87d6fec957 Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Sun, 16 Jan 2022 11:30:26 +0100 Subject: [PATCH] cinecalidad: fix parser. only latino is supported. resolves #12830 (#12833) --- src/Jackett.Common/Indexers/Cinecalidad.cs | 71 +++++++--------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/src/Jackett.Common/Indexers/Cinecalidad.cs b/src/Jackett.Common/Indexers/Cinecalidad.cs index fe9b9d876..8644a26c7 100644 --- a/src/Jackett.Common/Indexers/Cinecalidad.cs +++ b/src/Jackett.Common/Indexers/Cinecalidad.cs @@ -20,9 +20,8 @@ namespace Jackett.Common.Indexers [ExcludeFromCodeCoverage] public class Cinecalidad : BaseWebIndexer { - private const int MaxItemsPerPage = 15; - private const int MaxSearchPageLimit = 6; // 15 items per page * 6 pages = 90 - private string _language; + private const int MaxLatestPageLimit = 3; // 10 items per page * 3 pages = 30 + private const int MaxSearchPageLimit = 6; public override string[] LegacySiteLinks { get; protected set; } = { "https://cinecalidad.website/", @@ -41,7 +40,7 @@ namespace Jackett.Common.Indexers ICacheService cs) : base(id: "cinecalidad", name: "Cinecalidad", - description: "PelĂ­culas Full HD en Castellano y Latino Dual.", + description: "PelĂ­culas Full HD en Latino Dual.", link: "https://www.cinecalidad.lat/", caps: new TorznabCapabilities { @@ -55,32 +54,12 @@ namespace Jackett.Common.Indexers configData: new ConfigurationData()) { Encoding = Encoding.UTF8; - Language = "es-ES"; + Language = "es-419"; Type = "public"; - var language = new ConfigurationData.SingleSelectConfigurationItem( - "Select language", new Dictionary - { - {"castellano", "Castilian Spanish"}, - {"latino", "Latin American Spanish"} - }) - { - Value = "castellano" - }; - configData.AddDynamic("language", language); - AddCategoryMapping(1, TorznabCatType.MoviesHD); } - public override void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false) - { - { - base.LoadValuesFromJson(jsonConfig, useProtectionService); - var language = (ConfigurationData.SingleSelectConfigurationItem)configData.GetDynamic("language"); - _language = language?.Value ?? "castellano"; - } - } - public override async Task ApplyConfiguration(JToken configJson) { LoadValuesFromJson(configJson); @@ -97,11 +76,9 @@ namespace Jackett.Common.Indexers var releases = new List(); var templateUrl = SiteLink; - if (_language.Equals("castellano")) - templateUrl += "espana/"; templateUrl += "{0}?s="; // placeholder for page - var maxPages = 2; // we scrape only 2 pages for recent torrents + var maxPages = MaxLatestPageLimit; // we scrape only 2 pages for recent torrents if (!string.IsNullOrWhiteSpace(query.GetQueryString())) { templateUrl += WebUtilityHelpers.UrlEncode(query.GetQueryString(), Encoding.UTF8); @@ -124,7 +101,7 @@ namespace Jackett.Common.Indexers } releases.AddRange(pageReleases); - if (pageReleases.Count < MaxItemsPerPage) + if (pageReleases.Count < 1) break; // this is the last page } @@ -139,19 +116,8 @@ namespace Jackett.Common.Indexers { var parser = new HtmlParser(); var dom = parser.ParseDocument(results.ContentString); - var linkParent = dom.QuerySelector("li:contains('Torrent')").ParentElement; - var protectedLink = linkParent.GetAttribute("data-res"); - if (protectedLink != null) - protectedLink = "protect/v.php?i=" + protectedLink; - else - protectedLink = linkParent.GetAttribute("href"); - if (protectedLink.Contains("/ouo.io/")) - { - // protected link => - // https://ouo.io/qs/qsW6rCh4?s=https://www.cinecalidad.is/protect/v2.php?i=A8--9InL&title=High+Life+%282018%29 - var linkParts = protectedLink.Split('='); - protectedLink = protectedLink.Replace(linkParts[0] + "=", ""); - } + var protectedLink = dom.QuerySelector("a:contains('Torrent')").GetAttribute("data-url"); + protectedLink = Base64Decode(protectedLink); protectedLink = GetAbsoluteUrl(protectedLink); results = await RequestWithCookiesAsync(protectedLink); @@ -179,17 +145,20 @@ namespace Jackett.Common.Indexers var rows = dom.QuerySelectorAll("article"); foreach (var row in rows) { + if (row.QuerySelector("div.selt") != null) + continue; // we only support movies + + var qLink = row.QuerySelector("a.absolute"); var qImg = row.QuerySelector("img"); - if (qImg == null) + if (qLink == null || qImg == null) continue; // skip results without image - var title = qImg.GetAttribute("alt"); + + var title = qLink.TextContent.Trim(); if (!CheckTitleMatchWords(query.GetQueryString(), title)) continue; // skip if it doesn't contain all words - title += _language.Equals("castellano") ? " MULTi/SPANiSH" : " MULTi/LATiN SPANiSH"; - title += " 1080p BDRip x264"; - + title += " MULTi/LATiN SPANiSH 1080p BDRip x264"; var poster = new Uri(GetAbsoluteUrl(qImg.GetAttribute("src"))); - var link = new Uri(row.QuerySelector("a").GetAttribute("href")); + var link = new Uri(qLink.GetAttribute("href")); var release = new ReleaseInfo { @@ -243,6 +212,12 @@ namespace Jackett.Common.Indexers return SiteLink + url.TrimStart('/'); return url; } + + private string Base64Decode(string base64EncodedData) + { + var base64EncodedBytes = Convert.FromBase64String(base64EncodedData); + return Encoding.UTF8.GetString(base64EncodedBytes); + } } }