mirror of
https://github.com/Jackett/Jackett
synced 2025-03-12 15:14:50 +00:00
cinecalidad: parse 4k releases (#14677)
This commit is contained in:
parent
3cf4166e15
commit
937593b306
2 changed files with 87 additions and 18 deletions
18
src/Jackett.Common/Extensions/UriExtensions.cs
Normal file
18
src/Jackett.Common/Extensions/UriExtensions.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace Jackett.Common.Extensions
|
||||
{
|
||||
public static class UriExtensions
|
||||
{
|
||||
public static Uri AddQueryParameter(this Uri url, string paramName, string paramValue)
|
||||
{
|
||||
var uriBuilder = new UriBuilder(url);
|
||||
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
query[paramName] = paramValue;
|
||||
uriBuilder.Query = query.ToString();
|
||||
|
||||
return uriBuilder.Uri;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using AngleSharp.Html.Parser;
|
||||
using Jackett.Common.Extensions;
|
||||
using Jackett.Common.Helpers;
|
||||
using Jackett.Common.Models;
|
||||
using Jackett.Common.Models.IndexerConfig;
|
||||
|
@ -13,7 +14,6 @@ using Jackett.Common.Services.Interfaces;
|
|||
using Jackett.Common.Utils.Clients;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using WebClient = Jackett.Common.Utils.Clients.WebClient;
|
||||
|
||||
namespace Jackett.Common.Indexers
|
||||
|
@ -74,6 +74,7 @@ namespace Jackett.Common.Indexers
|
|||
};
|
||||
|
||||
caps.Categories.AddCategoryMapping(1, TorznabCatType.MoviesHD);
|
||||
caps.Categories.AddCategoryMapping(2, TorznabCatType.MoviesUHD);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ namespace Jackett.Common.Indexers
|
|||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
LoadValuesFromJson(configJson);
|
||||
|
||||
var releases = await PerformQuery(new TorznabQuery());
|
||||
|
||||
await ConfigureIfOK(string.Empty, releases.Any(), () =>
|
||||
|
@ -97,6 +99,7 @@ namespace Jackett.Common.Indexers
|
|||
templateUrl += "{0}?s="; // placeholder for page
|
||||
|
||||
var maxPages = MaxLatestPageLimit; // we scrape only 3 pages for recent torrents
|
||||
|
||||
var recent = !string.IsNullOrWhiteSpace(query.GetQueryString());
|
||||
if (recent)
|
||||
{
|
||||
|
@ -121,7 +124,10 @@ namespace Jackett.Common.Indexers
|
|||
releases.AddRange(pageReleases);
|
||||
|
||||
if (pageReleases.Count < 1 && recent)
|
||||
break; // this is the last page
|
||||
{
|
||||
// this is the last page
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return releases;
|
||||
|
@ -129,13 +135,25 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
public override async Task<byte[]> Download(Uri link)
|
||||
{
|
||||
var parser = new HtmlParser();
|
||||
|
||||
var results = await RequestWithCookiesAsync(link.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(results.ContentString);
|
||||
var protectedLink = dom.QuerySelector("a:contains('Torrent')").GetAttribute("data-url");
|
||||
var dom = await parser.ParseDocumentAsync(results.ContentString);
|
||||
|
||||
var downloadLink = link.Query.Contains("type=4k")
|
||||
? dom.QuerySelector("ul.links a:contains('Bittorrent 4K')")
|
||||
: dom.QuerySelector("ul.links a:contains('Torrent')");
|
||||
|
||||
var protectedLink = downloadLink?.GetAttribute("data-url");
|
||||
|
||||
if (protectedLink.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new Exception($"Invalid download link for {link}");
|
||||
}
|
||||
|
||||
protectedLink = Base64Decode(protectedLink);
|
||||
// turn
|
||||
// link=https://cinecalidad.dev/pelicula/la-chica-salvaje/
|
||||
|
@ -145,7 +163,7 @@ namespace Jackett.Common.Indexers
|
|||
// https://cinecalidad.dev/pelicula/la-chica-salvaje/?link=MS8xMDA5NTIvMQ==
|
||||
var protectedLinkSplit = protectedLink.Split('/');
|
||||
var key = protectedLinkSplit.Last();
|
||||
protectedLink = link.ToString() + "?link=" + key;
|
||||
protectedLink = link.AddQueryParameter("link", key).ToString();
|
||||
protectedLink = GetAbsoluteUrl(protectedLink);
|
||||
|
||||
results = await RequestWithCookiesAsync(protectedLink);
|
||||
|
@ -170,30 +188,40 @@ namespace Jackett.Common.Indexers
|
|||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(response.ContentString);
|
||||
|
||||
var rows = dom.QuerySelectorAll("article");
|
||||
var rows = dom.QuerySelectorAll("article:has(a.absolute):has(img.rounded)");
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
if (row.QuerySelector("div.selt") != null)
|
||||
continue; // we only support movies
|
||||
{
|
||||
// we only support movies
|
||||
continue;
|
||||
}
|
||||
|
||||
var qLink = row.QuerySelector("a.absolute");
|
||||
var qImg = row.QuerySelector("img.rounded");
|
||||
if (qLink == null || qImg == null)
|
||||
continue; // skip results without image
|
||||
{
|
||||
// skip results without image
|
||||
continue;
|
||||
}
|
||||
|
||||
var title = qLink.TextContent.Trim();
|
||||
if (!CheckTitleMatchWords(query.GetQueryString(), title))
|
||||
continue; // skip if it doesn't contain all words
|
||||
title += " MULTi/LATiN SPANiSH 1080p BDRip x264";
|
||||
var poster = new Uri(GetAbsoluteUrl(qImg.GetAttribute("src")));
|
||||
{
|
||||
// skip if it doesn't contain all words
|
||||
continue;
|
||||
}
|
||||
|
||||
var poster = new Uri(GetAbsoluteUrl(qImg.GetAttribute("data-src") ?? qImg.GetAttribute("src")));
|
||||
var link = new Uri(qLink.GetAttribute("href"));
|
||||
|
||||
var release = new ReleaseInfo
|
||||
releases.Add(new ReleaseInfo
|
||||
{
|
||||
Title = title,
|
||||
Link = link,
|
||||
Details = link,
|
||||
Guid = link,
|
||||
Details = link,
|
||||
Link = link,
|
||||
Title = $"{title} MULTi/LATiN SPANiSH 1080p BDRip x264",
|
||||
Category = new List<int> { TorznabCatType.MoviesHD.ID },
|
||||
Poster = poster,
|
||||
Size = 2147483648, // 2 GB
|
||||
|
@ -202,9 +230,28 @@ namespace Jackett.Common.Indexers
|
|||
Peers = 2,
|
||||
DownloadVolumeFactor = 0,
|
||||
UploadVolumeFactor = 1
|
||||
};
|
||||
});
|
||||
|
||||
releases.Add(release);
|
||||
if (row.QuerySelector("a[aria-label=\"4K\"]") != null)
|
||||
{
|
||||
var link4K = link.AddQueryParameter("type", "4k");
|
||||
|
||||
releases.Add(new ReleaseInfo
|
||||
{
|
||||
Guid = link4K,
|
||||
Details = link,
|
||||
Link = link4K,
|
||||
Title = $"{title} MULTi/LATiN SPANiSH 2160p BDRip x264",
|
||||
Category = new List<int> { TorznabCatType.MoviesUHD.ID },
|
||||
Poster = poster,
|
||||
Size = 10737418240, // 2 GB
|
||||
Files = 1,
|
||||
Seeders = 1,
|
||||
Peers = 2,
|
||||
DownloadVolumeFactor = 0,
|
||||
UploadVolumeFactor = 1
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -236,8 +283,12 @@ namespace Jackett.Common.Indexers
|
|||
private string GetAbsoluteUrl(string url)
|
||||
{
|
||||
url = url.Trim();
|
||||
|
||||
if (!url.StartsWith("http"))
|
||||
{
|
||||
return SiteLink + url.TrimStart('/');
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue