2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2018-05-12 01:55:24 +00:00
|
|
|
using System.Collections.Generic;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2018-05-12 01:55:24 +00:00
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Threading.Tasks;
|
2019-01-20 00:09:27 +00:00
|
|
|
using AngleSharp.Html.Parser;
|
2018-05-12 01:55:24 +00:00
|
|
|
using Jackett.Common.Models;
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils.Clients;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
|
|
|
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
|
|
|
|
|
|
|
|
namespace Jackett.Common.Indexers
|
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2020-05-11 22:58:10 +00:00
|
|
|
public class NewPCT : BaseCachingWebIndexer
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
private enum ReleaseType
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-03-29 20:40:31 +00:00
|
|
|
Tv,
|
2020-10-19 21:19:10 +00:00
|
|
|
Movie
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
private class NewpctRelease : ReleaseInfo
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2018-08-29 09:21:07 +00:00
|
|
|
public ReleaseType NewpctReleaseType;
|
|
|
|
public string SeriesName;
|
2018-05-12 01:55:24 +00:00
|
|
|
public int? Season;
|
|
|
|
public int? Episode;
|
|
|
|
public int? EpisodeTo;
|
2018-11-19 10:50:24 +00:00
|
|
|
public int Score;
|
2018-08-29 09:21:07 +00:00
|
|
|
|
|
|
|
public NewpctRelease()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-19 10:50:24 +00:00
|
|
|
public NewpctRelease(NewpctRelease copyFrom) :
|
2018-08-29 09:21:07 +00:00
|
|
|
base(copyFrom)
|
|
|
|
{
|
|
|
|
NewpctReleaseType = copyFrom.NewpctReleaseType;
|
|
|
|
SeriesName = copyFrom.SeriesName;
|
|
|
|
Season = copyFrom.Season;
|
|
|
|
Episode = copyFrom.Episode;
|
|
|
|
EpisodeTo = copyFrom.EpisodeTo;
|
2018-11-19 10:50:24 +00:00
|
|
|
Score = copyFrom.Score;
|
2018-08-29 09:21:07 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 16:08:03 +00:00
|
|
|
public override object Clone() => new NewpctRelease(this);
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
private class DownloadMatcher
|
2019-06-13 22:41:34 +00:00
|
|
|
{
|
|
|
|
public Regex MatchRegex;
|
|
|
|
public MatchEvaluator MatchEvaluator;
|
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
private readonly char[] _wordSeparators = { ' ', '.', ',', ';', '(', ')', '[', ']', '-', '_' };
|
2020-02-10 22:16:19 +00:00
|
|
|
private readonly int _wordNotFoundScore = 100000;
|
2020-04-25 01:33:13 +00:00
|
|
|
private readonly Regex _searchStringRegex = new Regex(@"(.+?)S(\d{2})(E(\d{2}))?$", RegexOptions.IgnoreCase);
|
2020-05-20 04:19:14 +00:00
|
|
|
// Defending Jacob Temp. 1 Capitulo 1
|
|
|
|
private readonly Regex _seriesChapterTitleRegex = new Regex(@"(.+)Temp. (\d+) Capitulo (\d+)", RegexOptions.IgnoreCase);
|
|
|
|
// Love 101 - Temp. 1 Capitulos 1 al 8
|
|
|
|
private readonly Regex _seriesChaptersTitleRegex = new Regex(@"(.+)Temp. (\d+) Capitulos (\d+) al (\d+)", RegexOptions.IgnoreCase);
|
2020-04-25 01:33:13 +00:00
|
|
|
private readonly Regex _titleYearRegex = new Regex(@" *[\[\(]? *((19|20)\d{2}) *[\]\)]? *$");
|
|
|
|
private readonly DownloadMatcher[] _downloadMatchers =
|
2019-06-13 22:41:34 +00:00
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
new DownloadMatcher
|
2020-01-12 03:25:26 +00:00
|
|
|
{
|
|
|
|
MatchRegex = new Regex("(/descargar-torrent/[^\"]+)\"")
|
|
|
|
},
|
2020-04-25 01:33:13 +00:00
|
|
|
new DownloadMatcher
|
2019-06-13 22:41:34 +00:00
|
|
|
{
|
2020-10-06 19:34:41 +00:00
|
|
|
MatchRegex = new Regex(@"window\.location\.href\s*=\s*""([^""]+)"""),
|
|
|
|
MatchEvaluator = m => $"https:{m.Groups[1]}"
|
2020-10-19 21:19:10 +00:00
|
|
|
}
|
2019-06-13 22:41:34 +00:00
|
|
|
};
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-10-12 21:35:13 +00:00
|
|
|
private readonly int _maxDailyPages = 1;
|
2020-04-25 01:33:13 +00:00
|
|
|
private readonly int _maxMoviesPages = 6;
|
|
|
|
private readonly int[] _allTvCategories = (new [] {TorznabCatType.TV }).Concat(TorznabCatType.TV.SubCategories).Select(c => c.ID).ToArray();
|
|
|
|
private readonly int[] _allMoviesCategories = (new [] { TorznabCatType.Movies }).Concat(TorznabCatType.Movies.SubCategories).Select(c => c.ID).ToArray();
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2018-10-20 05:48:53 +00:00
|
|
|
private bool _includeVo;
|
2018-11-19 10:50:24 +00:00
|
|
|
private bool _filterMovies;
|
2019-08-18 20:53:14 +00:00
|
|
|
private bool _removeMovieAccents;
|
2020-03-10 02:53:57 +00:00
|
|
|
private bool _removeMovieYear;
|
2018-08-29 09:21:07 +00:00
|
|
|
private DateTime _dailyNow;
|
|
|
|
private int _dailyResultIdx;
|
|
|
|
|
2020-10-12 21:35:13 +00:00
|
|
|
private readonly string _dailyUrl = "ultimas-descargas/pg/{0}";
|
2020-03-29 20:40:31 +00:00
|
|
|
private readonly string _searchJsonUrl = "get/result/";
|
|
|
|
private readonly string[] _seriesLetterUrls = { "series/letter/{0}", "series-hd/letter/{0}" };
|
|
|
|
private readonly string[] _seriesVoLetterUrls = { "series-vo/letter/{0}" };
|
|
|
|
private readonly string[] _voUrls = { "serie-vo", "serievo" };
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-10-08 18:51:34 +00:00
|
|
|
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
|
|
|
"https://pctmix.com/",
|
2021-03-14 02:59:20 +00:00
|
|
|
"https://pctmix1.com/",
|
|
|
|
"https://pctreload1.com/"
|
2020-10-08 18:51:34 +00:00
|
|
|
};
|
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
public override string[] LegacySiteLinks { get; protected set; } = {
|
|
|
|
"http://descargas2020.com/",
|
|
|
|
"http://www.tvsinpagar.com/",
|
|
|
|
"http://torrentlocura.com/",
|
|
|
|
"https://pctnew.site",
|
|
|
|
"https://descargas2020.site",
|
|
|
|
"http://torrentrapid.com/",
|
|
|
|
"http://tumejortorrent.com/",
|
|
|
|
"http://pctnew.com/",
|
2020-09-05 04:06:55 +00:00
|
|
|
"https://descargas2020.org/",
|
2021-03-14 02:59:20 +00:00
|
|
|
"https://pctnew.org/",
|
|
|
|
"https://pctreload.com/"
|
2020-03-29 20:40:31 +00:00
|
|
|
};
|
2018-12-16 00:40:40 +00:00
|
|
|
|
2020-12-11 22:14:21 +00:00
|
|
|
public NewPCT(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
|
|
|
|
ICacheService cs)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "newpct",
|
2020-05-11 22:58:10 +00:00
|
|
|
name: "NewPCT",
|
|
|
|
description: "NewPCT - Descargar peliculas, series y estrenos torrent gratis",
|
2020-10-06 19:34:41 +00:00
|
|
|
link: "https://pctmix.com/",
|
2020-10-18 17:26:22 +00:00
|
|
|
caps: new TorznabCapabilities {
|
2020-10-18 20:47:36 +00:00
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
|
|
|
|
},
|
|
|
|
MovieSearchParams = new List<MovieSearchParam>
|
|
|
|
{
|
|
|
|
MovieSearchParam.Q
|
|
|
|
}
|
2020-10-18 17:26:22 +00:00
|
|
|
},
|
2020-04-25 01:33:13 +00:00
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-12-11 22:14:21 +00:00
|
|
|
cacheService: cs,
|
2020-04-25 01:33:13 +00:00
|
|
|
configData: new ConfigurationData())
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
|
|
|
Encoding = Encoding.GetEncoding("windows-1252");
|
|
|
|
Language = "es-es";
|
|
|
|
Type = "public";
|
|
|
|
|
2021-03-16 23:29:26 +00:00
|
|
|
var voItem = new BoolConfigurationItem("Include original versions in search results") { Value = false };
|
2018-05-12 01:55:24 +00:00
|
|
|
configData.AddDynamic("IncludeVo", voItem);
|
2018-11-19 10:50:24 +00:00
|
|
|
|
2021-03-16 23:29:26 +00:00
|
|
|
var filterMoviesItem = new BoolConfigurationItem("Only full match movies") { Value = true };
|
2018-11-19 10:50:24 +00:00
|
|
|
configData.AddDynamic("FilterMovies", filterMoviesItem);
|
2019-08-18 20:53:14 +00:00
|
|
|
|
2021-03-16 23:29:26 +00:00
|
|
|
var removeMovieAccentsItem = new BoolConfigurationItem("Remove accents in movie searches") { Value = true };
|
2019-08-18 20:53:14 +00:00
|
|
|
configData.AddDynamic("RemoveMovieAccents", removeMovieAccentsItem);
|
2020-03-10 02:53:57 +00:00
|
|
|
|
2021-03-16 23:29:26 +00:00
|
|
|
var removeMovieYearItem = new BoolConfigurationItem("Remove year from movie results (enable for Radarr)") { Value = false };
|
2020-03-10 02:53:57 +00:00
|
|
|
configData.AddDynamic("RemoveMovieYear", removeMovieYearItem);
|
2020-10-18 17:26:22 +00:00
|
|
|
|
|
|
|
AddCategoryMapping(1, TorznabCatType.Movies);
|
|
|
|
AddCategoryMapping(2, TorznabCatType.TV);
|
|
|
|
AddCategoryMapping(3, TorznabCatType.TVSD);
|
|
|
|
AddCategoryMapping(4, TorznabCatType.TVHD);
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2020-03-29 20:40:31 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
var results = await PerformQuery(new TorznabQuery());
|
|
|
|
if (!results.Any())
|
|
|
|
throw new Exception("Found 0 releases!");
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
IsConfigured = true;
|
|
|
|
SaveConfig();
|
2018-05-12 01:55:24 +00:00
|
|
|
return IndexerConfigurationStatus.Completed;
|
|
|
|
}
|
|
|
|
|
2018-12-14 21:56:33 +00:00
|
|
|
public override async Task<byte[]> Download(Uri linkParam)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-06-11 15:09:27 +00:00
|
|
|
var results = await RequestWithCookiesAndRetryAsync(linkParam.AbsoluteUri);
|
2018-12-14 21:56:33 +00:00
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
var uriLink = ExtractDownloadUri(results.ContentString, linkParam.AbsoluteUri);
|
2020-03-29 20:40:31 +00:00
|
|
|
if (uriLink == null)
|
|
|
|
throw new Exception("Download link not found!");
|
2018-12-14 21:56:33 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
return await base.Download(uriLink);
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
2019-06-13 22:41:34 +00:00
|
|
|
private Uri ExtractDownloadUri(string content, string baseLink)
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
foreach (var matcher in _downloadMatchers)
|
2019-06-13 22:41:34 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var match = matcher.MatchRegex.Match(content);
|
2019-06-13 22:41:34 +00:00
|
|
|
if (match.Success)
|
|
|
|
{
|
2019-12-09 23:25:25 +00:00
|
|
|
string linkText;
|
|
|
|
|
2019-06-13 22:41:34 +00:00
|
|
|
if (matcher.MatchEvaluator != null)
|
|
|
|
linkText = (string)matcher.MatchEvaluator.DynamicInvoke(match);
|
|
|
|
else
|
|
|
|
linkText = match.Groups[1].Value;
|
|
|
|
|
|
|
|
return new Uri(new Uri(baseLink), linkText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
2021-03-16 23:29:26 +00:00
|
|
|
_includeVo = ((BoolConfigurationItem)configData.GetDynamic("IncludeVo")).Value;
|
|
|
|
_filterMovies = ((BoolConfigurationItem)configData.GetDynamic("FilterMovies")).Value;
|
|
|
|
_removeMovieAccents = ((BoolConfigurationItem)configData.GetDynamic("RemoveMovieAccents")).Value;
|
|
|
|
_removeMovieYear = ((BoolConfigurationItem)configData.GetDynamic("RemoveMovieYear")).Value;
|
2018-08-29 09:21:07 +00:00
|
|
|
_dailyNow = DateTime.Now;
|
|
|
|
_dailyResultIdx = 0;
|
2020-02-10 22:16:19 +00:00
|
|
|
var rssMode = string.IsNullOrEmpty(query.SanitizedSearchTerm);
|
2018-05-12 01:55:24 +00:00
|
|
|
|
|
|
|
if (rssMode)
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var pg = 1;
|
2018-05-12 01:55:24 +00:00
|
|
|
while (pg <= _maxDailyPages)
|
|
|
|
{
|
2020-03-29 20:40:31 +00:00
|
|
|
var pageUrl = SiteLink + string.Format(_dailyUrl, pg);
|
2020-06-11 15:09:27 +00:00
|
|
|
var results = await RequestWithCookiesAndRetryAsync(pageUrl);
|
2020-06-09 17:36:57 +00:00
|
|
|
if (results == null || string.IsNullOrEmpty(results.ContentString))
|
2020-03-29 20:40:31 +00:00
|
|
|
break;
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
var items = ParseDailyContent(results.ContentString);
|
2018-05-12 01:55:24 +00:00
|
|
|
if (items == null || !items.Any())
|
|
|
|
break;
|
|
|
|
|
|
|
|
releases.AddRange(items);
|
|
|
|
pg++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var isTvSearch = query.Categories == null || query.Categories.Length == 0 ||
|
2018-05-12 01:55:24 +00:00
|
|
|
query.Categories.Any(c => _allTvCategories.Contains(c));
|
|
|
|
if (isTvSearch)
|
2020-03-29 20:40:31 +00:00
|
|
|
releases.AddRange(await TvSearch(query));
|
2018-11-19 10:50:24 +00:00
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var isMovieSearch = query.Categories == null || query.Categories.Length == 0 ||
|
2018-11-19 10:50:24 +00:00
|
|
|
query.Categories.Any(c => _allMoviesCategories.Contains(c));
|
|
|
|
if (isMovieSearch)
|
2020-10-12 21:35:13 +00:00
|
|
|
releases.AddRange(await MovieSearch(query));
|
2018-07-03 12:29:06 +00:00
|
|
|
}
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-02-08 01:49:33 +00:00
|
|
|
// Database lost on 2018/04/05, all previous torrents don't have download links
|
|
|
|
var failureDay = new DateTime(2018, 04, 05);
|
|
|
|
releases = releases.Where(r => r.PublishDate > failureDay).ToList();
|
|
|
|
|
2018-07-03 12:29:06 +00:00
|
|
|
return releases;
|
|
|
|
}
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
private async Task<IEnumerable<ReleaseInfo>> TvSearch(TorznabQuery query)
|
2018-07-03 12:29:06 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var seriesName = query.SanitizedSearchTerm;
|
|
|
|
var season = query.Season > 0 ? (int?)query.Season : null;
|
2018-07-03 12:29:06 +00:00
|
|
|
int? episode = null;
|
2020-02-10 22:16:19 +00:00
|
|
|
if (!string.IsNullOrWhiteSpace(query.Episode) && int.TryParse(query.Episode, out var episodeTemp))
|
2018-07-03 12:29:06 +00:00
|
|
|
episode = episodeTemp;
|
|
|
|
|
|
|
|
//If query has no season/episode info, try to parse title
|
|
|
|
if (season == null && episode == null)
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var searchMatch = _searchStringRegex.Match(query.SanitizedSearchTerm);
|
2018-07-03 12:29:06 +00:00
|
|
|
if (searchMatch.Success)
|
|
|
|
{
|
|
|
|
seriesName = searchMatch.Groups[1].Value.Trim();
|
|
|
|
season = int.Parse(searchMatch.Groups[2].Value);
|
|
|
|
episode = searchMatch.Groups[4].Success ? (int?)int.Parse(searchMatch.Groups[4].Value) : null;
|
|
|
|
}
|
|
|
|
}
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2018-07-03 12:29:06 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
//Search series url
|
|
|
|
foreach (var seriesListUrl in SeriesListUris(seriesName))
|
|
|
|
releases.AddRange(await GetReleasesFromUri(seriesListUrl, seriesName));
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
//Sonarr removes "the" from shows. If there is nothing try prepending "the"
|
|
|
|
if (releases.Count == 0 && !(seriesName.ToLower().StartsWith("the")))
|
|
|
|
{
|
|
|
|
seriesName = "The " + seriesName;
|
|
|
|
foreach (var seriesListUrl in SeriesListUris(seriesName))
|
|
|
|
releases.AddRange(await GetReleasesFromUri(seriesListUrl, seriesName));
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-12 03:25:26 +00:00
|
|
|
// remove duplicates
|
2020-03-29 20:40:31 +00:00
|
|
|
releases = releases.GroupBy(x => x.Guid).Select(y => y.First()).ToList();
|
2020-01-12 03:25:26 +00:00
|
|
|
|
2018-07-03 12:29:06 +00:00
|
|
|
//Filter only episodes needed
|
2020-03-29 20:40:31 +00:00
|
|
|
return releases.Where(r =>
|
2018-07-03 12:29:06 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var nr = r as NewpctRelease;
|
2018-10-20 05:48:53 +00:00
|
|
|
return (
|
|
|
|
nr.Season.HasValue != season.HasValue || //Can't determine if same season
|
2018-07-03 12:29:06 +00:00
|
|
|
nr.Season.HasValue && season.Value == nr.Season.Value && //Same season and ...
|
|
|
|
(
|
|
|
|
nr.Episode.HasValue != episode.HasValue || //Can't determine if same episode
|
|
|
|
nr.Episode.HasValue &&
|
|
|
|
(
|
|
|
|
nr.Episode.Value == episode.Value || //Same episode
|
|
|
|
nr.EpisodeTo.HasValue && episode.Value >= nr.Episode.Value && episode.Value <= nr.EpisodeTo.Value //Episode in interval
|
|
|
|
)
|
2018-10-20 05:48:53 +00:00
|
|
|
)
|
|
|
|
);
|
2018-07-03 12:29:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
private async Task<List<ReleaseInfo>> GetReleasesFromUri(Uri uri, string seriesName)
|
2018-07-03 12:29:06 +00:00
|
|
|
{
|
2020-03-29 20:40:31 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2018-07-03 12:29:06 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
// Episodes list
|
2020-06-11 15:09:27 +00:00
|
|
|
var results = await RequestWithCookiesAndRetryAsync(uri.AbsoluteUri);
|
2020-06-09 17:36:57 +00:00
|
|
|
var seriesEpisodesUrl = ParseSeriesListContent(results.ContentString, seriesName);
|
2020-03-29 20:40:31 +00:00
|
|
|
|
|
|
|
// TV serie list
|
2018-07-03 12:29:06 +00:00
|
|
|
if (!string.IsNullOrEmpty(seriesEpisodesUrl))
|
|
|
|
{
|
2020-06-11 15:09:27 +00:00
|
|
|
results = await RequestWithCookiesAndRetryAsync(seriesEpisodesUrl);
|
2020-06-09 17:36:57 +00:00
|
|
|
var items = ParseEpisodesListContent(results.ContentString);
|
2020-03-29 20:40:31 +00:00
|
|
|
if (items != null && items.Any())
|
2020-04-07 16:17:17 +00:00
|
|
|
releases.AddRange(items);
|
2018-07-03 12:29:06 +00:00
|
|
|
}
|
2020-03-29 20:40:31 +00:00
|
|
|
return releases;
|
2018-07-03 12:29:06 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
private IEnumerable<Uri> SeriesListUris(string seriesName)
|
2018-07-03 12:29:06 +00:00
|
|
|
{
|
|
|
|
IEnumerable<string> lettersUrl;
|
2018-10-20 05:48:53 +00:00
|
|
|
if (!_includeVo)
|
2018-07-03 12:29:06 +00:00
|
|
|
lettersUrl = _seriesLetterUrls;
|
|
|
|
else
|
2020-03-29 20:40:31 +00:00
|
|
|
lettersUrl = _seriesLetterUrls.Concat(_seriesVoLetterUrls);
|
2020-02-10 22:16:19 +00:00
|
|
|
var seriesLetter = !char.IsDigit(seriesName[0]) ? seriesName[0].ToString() : "0-9";
|
2020-03-29 20:40:31 +00:00
|
|
|
return lettersUrl.Select(
|
|
|
|
urlFormat => new Uri(SiteLink + string.Format(urlFormat, seriesLetter.ToLower())));
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
private List<NewpctRelease> ParseDailyContent(string content)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-03-29 20:40:31 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var doc = parser.ParseDocument(content);
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var releases = new List<NewpctRelease>();
|
2018-05-12 01:55:24 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2020-10-12 21:35:13 +00:00
|
|
|
var rows = doc.QuerySelectorAll("div.page-box > ul > li");
|
2018-05-12 01:55:24 +00:00
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
var qDiv = row.QuerySelector("div.info");
|
|
|
|
var title = qDiv.QuerySelector("h2").TextContent.Trim();
|
2020-10-12 21:35:13 +00:00
|
|
|
var detailsUrl = SiteLink + qDiv.QuerySelector("a").GetAttribute("href").TrimStart('/');
|
2018-08-29 09:21:07 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
// TODO: move this check to GetReleaseFromData to apply all releases
|
2018-10-20 05:48:53 +00:00
|
|
|
if (!_includeVo && _voUrls.Any(vo => detailsUrl.ToLower().Contains(vo.ToLower())))
|
|
|
|
continue;
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
var span = qDiv.QuerySelector("span");
|
2018-05-12 01:55:24 +00:00
|
|
|
var quality = span.ChildNodes[0].TextContent.Trim();
|
2020-02-10 22:16:19 +00:00
|
|
|
var releaseType = ReleaseTypeFromQuality(quality);
|
2020-04-25 01:33:13 +00:00
|
|
|
var sizeString = span.ChildNodes[1].TextContent.Replace("Tama\u00F1o", "").Trim();
|
|
|
|
var size = ReleaseInfo.GetBytes(sizeString);
|
|
|
|
|
|
|
|
var language = qDiv.QuerySelector("div > strong").TextContent.Trim();
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2018-08-29 09:21:07 +00:00
|
|
|
_dailyResultIdx++;
|
2020-04-25 01:33:13 +00:00
|
|
|
var publishDate = _dailyNow - TimeSpan.FromMilliseconds(_dailyResultIdx);
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-11-07 23:43:33 +00:00
|
|
|
var poster = "https:" + row.QuerySelector("img").GetAttribute("src");
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-11-07 23:43:33 +00:00
|
|
|
var release = GetReleaseFromData(releaseType, title, detailsUrl, quality, language, size, publishDate, poster);
|
2020-03-29 20:40:31 +00:00
|
|
|
releases.Add(release);
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(content, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
|
|
|
|
private string ParseSeriesListContent(string content, string title)
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
var titleLower = title.Trim().ToLower();
|
2020-03-29 20:40:31 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var doc = parser.ParseDocument(content);
|
2018-05-12 01:55:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var rows = doc.QuerySelectorAll(".pelilist li a");
|
2020-04-25 01:33:13 +00:00
|
|
|
foreach (var row in rows)
|
|
|
|
if (titleLower.Equals(row.QuerySelector("h2").TextContent.Trim().ToLower()))
|
|
|
|
return row.GetAttribute("href");
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(content, ex);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
private List<NewpctRelease> ParseEpisodesListContent(string content)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-03-29 20:40:31 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var doc = parser.ParseDocument(content);
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var releases = new List<NewpctRelease>();
|
2018-05-12 01:55:24 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
var rows = doc.QuerySelectorAll("ul.buscar-list > li");
|
2018-05-12 01:55:24 +00:00
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
var qDiv = row.QuerySelector("div.info");
|
|
|
|
var qTitle = qDiv.QuerySelector("h2");
|
|
|
|
if (qTitle.Children.Length == 0)
|
|
|
|
continue; // we skip episodes with old title (those torrents can't be downloaded anyway)
|
|
|
|
var title = qTitle.Children[0].TextContent.Trim();
|
|
|
|
var language = qTitle.Children[1].TextContent.Trim();
|
|
|
|
var quality = qTitle.Children[2].TextContent.Replace("[", "").Replace("]", "").Trim();
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
var detailsUrl = qDiv.QuerySelector("a").GetAttribute("href");
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
var publishDate = DateTime.ParseExact(qDiv.ChildNodes[3].TextContent.Trim(), "dd-MM-yyyy", null);
|
|
|
|
var size = ReleaseInfo.GetBytes(qDiv.ChildNodes[5].TextContent.Trim());
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-11-07 23:43:33 +00:00
|
|
|
var poster = "https:" + row.QuerySelector("img").GetAttribute("src");
|
2020-04-25 01:33:13 +00:00
|
|
|
|
2020-11-07 23:43:33 +00:00
|
|
|
var release = GetReleaseFromData(ReleaseType.Tv, title, detailsUrl, quality, language, size, publishDate, poster);
|
2020-03-29 20:40:31 +00:00
|
|
|
releases.Add(release);
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(content, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:35:13 +00:00
|
|
|
private async Task<IEnumerable<ReleaseInfo>> MovieSearch(TorznabQuery query)
|
2018-11-19 10:50:24 +00:00
|
|
|
{
|
|
|
|
var releases = new List<NewpctRelease>();
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var searchStr = query.SanitizedSearchTerm;
|
2019-08-18 20:53:14 +00:00
|
|
|
if (_removeMovieAccents)
|
|
|
|
searchStr = RemoveDiacritics(searchStr);
|
2018-11-19 10:50:24 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
// we always remove the year in the search, even if _removeMovieYear is disabled
|
|
|
|
// and we save the year to add it in the title if required
|
|
|
|
var year = "";
|
|
|
|
var matchYear = _titleYearRegex.Match(searchStr);
|
|
|
|
if (matchYear.Success)
|
|
|
|
{
|
|
|
|
year = matchYear.Groups[1].Value;
|
|
|
|
searchStr = _titleYearRegex.Replace(searchStr, "");
|
|
|
|
}
|
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
var searchJsonUrl = SiteLink + _searchJsonUrl;
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var pg = 1;
|
2018-11-19 10:50:24 +00:00
|
|
|
while (pg <= _maxMoviesPages)
|
|
|
|
{
|
2020-03-26 22:15:28 +00:00
|
|
|
var queryCollection = new Dictionary<string, string>
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
{"ordenar", "Lo+Ultimo"},
|
|
|
|
{"inon", "Descendente"},
|
2020-03-29 20:40:31 +00:00
|
|
|
{"s", searchStr},
|
|
|
|
{"pg", pg.ToString()}
|
2020-03-26 22:15:28 +00:00
|
|
|
};
|
2018-11-19 10:50:24 +00:00
|
|
|
|
2020-09-21 16:39:47 +00:00
|
|
|
var results = await RequestWithCookiesAsync(searchJsonUrl, method: RequestType.POST, data: queryCollection);
|
2020-06-09 17:36:57 +00:00
|
|
|
var items = ParseSearchJsonContent(results.ContentString, year);
|
2020-04-25 01:33:13 +00:00
|
|
|
if (!items.Any())
|
2018-11-19 10:50:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
releases.AddRange(items);
|
|
|
|
pg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScoreReleases(releases, searchStr);
|
|
|
|
|
2020-10-12 21:35:13 +00:00
|
|
|
if (_filterMovies)
|
2018-11-19 10:50:24 +00:00
|
|
|
releases = releases.Where(r => r.Score < _wordNotFoundScore).ToList();
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
private List<NewpctRelease> ParseSearchJsonContent(string content, string year)
|
2019-09-28 20:57:03 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var releases = new List<NewpctRelease>();
|
2020-04-25 01:33:13 +00:00
|
|
|
if (string.IsNullOrWhiteSpace(content))
|
|
|
|
return releases;
|
2019-09-28 20:57:03 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var jo = JObject.Parse(content);
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var numItems = int.Parse(jo["data"]["items"].ToString());
|
|
|
|
for (var i = 0; i < numItems; i++)
|
2019-09-28 20:57:03 +00:00
|
|
|
{
|
|
|
|
var item = jo["data"]["torrents"]["0"][i.ToString()];
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var title = item["torrentName"].ToString();
|
2020-04-25 01:33:13 +00:00
|
|
|
var detailsUrl = SiteLink + item["guid"];
|
|
|
|
var quality = item["calidad"].ToString();
|
2020-04-30 16:26:24 +00:00
|
|
|
var sizeString = item["torrentSize"].ToString();
|
|
|
|
var size = !sizeString.Contains("NAN") ? ReleaseInfo.GetBytes(sizeString) : 0;
|
2020-04-25 01:33:13 +00:00
|
|
|
DateTime.TryParseExact(item["torrentDateAdded"].ToString(), "dd/MM/yyyy", null, DateTimeStyles.None, out var publishDate);
|
2020-11-07 23:43:33 +00:00
|
|
|
var poster = SiteLink + item["imagen"].ToString().TrimStart('/');
|
2020-04-25 01:33:13 +00:00
|
|
|
|
|
|
|
// we have another search for series
|
|
|
|
var titleLower = title.ToLower();
|
|
|
|
var isSeries = quality != null && quality.ToLower().Contains("hdtv");
|
|
|
|
var isGame = titleLower.Contains("pcdvd");
|
2019-09-28 20:57:03 +00:00
|
|
|
if (isSeries || isGame)
|
|
|
|
continue;
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
// at this point we assume that this is a movie release, we need to parse the title. examples:
|
|
|
|
// Quien Es Harry Crumb (1989) [BluRay 720p X264 MKV][AC3 5.1 Castellano][www.descargas2020.ORG]
|
|
|
|
// Harry Potter y la orden del Fenix [4K UHDrip][2160p][HDR][AC3 5.1 Castellano DTS 5.1-Ingles+Subs][ES-EN]
|
|
|
|
// Harry Potter Y El Misterio Del Principe [DVDFULL][Spanish][2009]
|
|
|
|
// Harry Potter 2 Y La Camara Secreta [DVD9 FULL][Spanish_English][Inc Subs.]
|
|
|
|
// The Avengers [DVDRIP][VOSE English_Subs. Español][2012]
|
|
|
|
// Harry Potter y las Reliquias de la Muerte Parte I.DVD5 [ DVDR] [AC3 5.1] [Multilenguaje] [2010]
|
|
|
|
// Joker (2019) 720p [Web Screener 720p ][Castellano][www.descargas2020.ORG][www.pctnew.ORG]
|
|
|
|
|
2020-05-05 22:46:31 +00:00
|
|
|
// remove quality and language from the title
|
|
|
|
var titleParts = title.Split('[');
|
|
|
|
title = titleParts[0].Replace("720p", "").Trim();
|
|
|
|
|
|
|
|
// quality in the field quality/calidad is wrong in many cases
|
|
|
|
if (!string.IsNullOrWhiteSpace(quality))
|
|
|
|
{
|
|
|
|
if (titleLower.Contains("720") && !quality.Contains("720"))
|
|
|
|
quality += " 720p";
|
|
|
|
if (titleLower.Contains("265") || titleLower.Contains("hevc"))
|
|
|
|
quality += " x265";
|
|
|
|
if (titleLower.Contains("dvdfull") || titleLower.Contains("dvd5") || titleLower.Contains("dvd9"))
|
|
|
|
quality = "DVDR";
|
2020-05-09 08:21:57 +00:00
|
|
|
if (titleLower.Contains("[web screener]") || titleLower.Contains("[hd-tc]"))
|
|
|
|
quality = "TS Screener";
|
2020-05-05 22:46:31 +00:00
|
|
|
}
|
|
|
|
else if (titleParts.Length > 2)
|
|
|
|
quality = titleParts[1].Replace("]", "").Replace("MKV", "").Trim();
|
|
|
|
|
|
|
|
// we have to guess the language (words DUAL or MULTI are not supported in Radarr)
|
2020-04-25 01:33:13 +00:00
|
|
|
var language = "spanish";
|
2020-11-25 01:05:47 +00:00
|
|
|
if (titleLower.Contains("latino")) language += " latino";
|
2020-04-25 01:33:13 +00:00
|
|
|
if ((titleLower.Contains("castellano") && titleLower.Contains("ingles")) ||
|
|
|
|
(titleLower.Contains("spanish") && titleLower.Contains("english")) ||
|
2020-05-05 22:46:31 +00:00
|
|
|
titleLower.Contains("[es-en]") || titleLower.Contains("multilenguaje"))
|
|
|
|
language += " english";
|
2020-04-25 01:33:13 +00:00
|
|
|
else if (titleLower.Contains("vose"))
|
|
|
|
language = "english vose";
|
|
|
|
|
2020-05-05 22:46:31 +00:00
|
|
|
// remove the movie year if the user chooses (the year in the title is wrong in many cases)
|
|
|
|
if (_removeMovieYear)
|
|
|
|
title = _titleYearRegex.Replace(title, "");
|
|
|
|
|
|
|
|
// we add the year from search if it's not in the title
|
2020-04-25 01:33:13 +00:00
|
|
|
if (!string.IsNullOrWhiteSpace(year) && !_titleYearRegex.Match(title).Success)
|
|
|
|
title += " " + year;
|
|
|
|
|
2020-11-07 23:43:33 +00:00
|
|
|
var release = GetReleaseFromData(ReleaseType.Movie, title, detailsUrl, quality, language, size, publishDate, poster);
|
2020-03-29 20:40:31 +00:00
|
|
|
releases.Add(release);
|
2019-09-28 20:57:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-25 01:33:13 +00:00
|
|
|
catch (Exception ex)
|
2019-09-28 20:57:03 +00:00
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
OnParseError(content, ex);
|
2019-09-28 20:57:03 +00:00
|
|
|
}
|
|
|
|
|
2018-11-19 10:50:24 +00:00
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ScoreReleases(IEnumerable<NewpctRelease> releases, string searchTerm)
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var searchWords = searchTerm.ToLower().Split(_wordSeparators, StringSplitOptions.None).
|
2018-11-19 10:50:24 +00:00
|
|
|
Select(s => s.Trim()).
|
|
|
|
Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
foreach (var release in releases)
|
2018-11-19 10:50:24 +00:00
|
|
|
{
|
|
|
|
release.Score = 0;
|
2020-02-10 22:16:19 +00:00
|
|
|
var releaseWords = release.Title.ToLower().Split(_wordSeparators, StringSplitOptions.None).
|
2018-11-19 10:50:24 +00:00
|
|
|
Select(s => s.Trim()).
|
|
|
|
Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
foreach (var search in searchWords)
|
2018-11-19 10:50:24 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var index = Array.IndexOf(releaseWords, search);
|
2018-11-19 10:50:24 +00:00
|
|
|
if (index >= 0)
|
|
|
|
{
|
|
|
|
release.Score += index;
|
|
|
|
releaseWords[index] = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
release.Score += _wordNotFoundScore;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 16:08:03 +00:00
|
|
|
private static ReleaseType ReleaseTypeFromQuality(string quality) =>
|
|
|
|
quality.Trim().ToLower().StartsWith("hdtv")
|
2020-03-29 20:40:31 +00:00
|
|
|
? ReleaseType.Tv
|
2020-02-25 16:08:03 +00:00
|
|
|
: ReleaseType.Movie;
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-03-29 20:40:31 +00:00
|
|
|
private NewpctRelease GetReleaseFromData(ReleaseType releaseType, string title, string detailsUrl, string quality,
|
2020-11-07 23:43:33 +00:00
|
|
|
string language, long size, DateTime publishDate, string poster)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-03-26 22:15:28 +00:00
|
|
|
var result = new NewpctRelease
|
|
|
|
{
|
|
|
|
NewpctReleaseType = releaseType
|
|
|
|
};
|
2018-05-12 01:55:24 +00:00
|
|
|
|
|
|
|
//Sanitize
|
2020-04-25 01:33:13 +00:00
|
|
|
title = title.Replace("-", "").Replace("(", "").Replace(")", "");
|
|
|
|
title = Regex.Replace(title, @"\s+", " ");
|
2018-05-12 01:55:24 +00:00
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
if (releaseType == ReleaseType.Tv)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
var match = _seriesChapterTitleRegex.Match(title);
|
|
|
|
if (match.Success)
|
2018-05-12 01:55:24 +00:00
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
result.SeriesName = match.Groups[1].Value.Trim();
|
|
|
|
result.Season = int.Parse(match.Groups[2].Value);
|
|
|
|
result.Episode = int.Parse(match.Groups[3].Value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
match = _seriesChaptersTitleRegex.Match(title);
|
|
|
|
if (match.Success)
|
|
|
|
{
|
|
|
|
result.SeriesName = match.Groups[1].Value.Trim();
|
|
|
|
result.Season = int.Parse(match.Groups[2].Value);
|
|
|
|
result.Episode = int.Parse(match.Groups[3].Value);
|
|
|
|
result.EpisodeTo = int.Parse(match.Groups[4].Value);
|
|
|
|
}
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
// tv series
|
|
|
|
var episodeText = "S" + result.Season.ToString().PadLeft(2, '0');
|
|
|
|
episodeText += "E" + result.Episode.ToString().PadLeft(2, '0');
|
|
|
|
episodeText += result.EpisodeTo.HasValue ? "-" + result.EpisodeTo.ToString().PadLeft(2, '0') : "";
|
|
|
|
result.Title = $"{result.SeriesName} {episodeText}";
|
2018-05-12 01:55:24 +00:00
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(quality) && (quality.Contains("720") || quality.Contains("1080")))
|
|
|
|
result.Category = new List<int> { TorznabCatType.TVHD.ID };
|
|
|
|
else
|
|
|
|
result.Category = new List<int> { TorznabCatType.TV.ID };
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
// movie
|
2018-05-12 01:55:24 +00:00
|
|
|
result.Title = title;
|
|
|
|
result.Category = new List<int> { TorznabCatType.Movies.ID };
|
|
|
|
}
|
|
|
|
|
2020-04-25 01:33:13 +00:00
|
|
|
result.Title = FixedTitle(result, quality, language);
|
2018-05-12 01:55:24 +00:00
|
|
|
result.Link = new Uri(detailsUrl);
|
2018-07-03 14:17:16 +00:00
|
|
|
result.Guid = result.Link;
|
2020-11-08 02:11:27 +00:00
|
|
|
result.Details = result.Link;
|
2018-05-12 01:55:24 +00:00
|
|
|
result.PublishDate = publishDate;
|
2020-11-07 23:43:33 +00:00
|
|
|
result.Poster = new Uri(poster);
|
2018-05-12 01:55:24 +00:00
|
|
|
result.Seeders = 1;
|
2020-04-25 01:33:13 +00:00
|
|
|
result.Peers = 2;
|
|
|
|
result.Size = size;
|
2019-12-13 22:30:16 +00:00
|
|
|
result.DownloadVolumeFactor = 0;
|
|
|
|
result.UploadVolumeFactor = 1;
|
2018-07-02 10:56:53 +00:00
|
|
|
|
2018-05-12 01:55:24 +00:00
|
|
|
return result;
|
|
|
|
}
|
2018-07-02 10:56:53 +00:00
|
|
|
|
2018-10-20 05:48:53 +00:00
|
|
|
private string FixedTitle(NewpctRelease release, string quality, string language)
|
2018-07-02 10:56:53 +00:00
|
|
|
{
|
2020-04-25 01:33:13 +00:00
|
|
|
var fixedLanguage = language.ToLower()
|
|
|
|
.Replace("español", "spanish")
|
|
|
|
.Replace("espanol", "spanish")
|
|
|
|
.Replace("castellano", "spanish")
|
|
|
|
.ToUpper();
|
|
|
|
|
|
|
|
var qualityLower = quality.ToLower();
|
|
|
|
var fixedQuality = quality.Replace("-", " ");
|
|
|
|
if (qualityLower.Contains("full"))
|
2020-05-05 22:46:31 +00:00
|
|
|
fixedQuality = qualityLower.Contains("4k") ? "BluRay 2160p COMPLETE x265" : "BluRay COMPLETE";
|
2020-04-25 01:33:13 +00:00
|
|
|
else if (qualityLower.Contains("remux"))
|
2020-05-05 22:46:31 +00:00
|
|
|
fixedQuality = qualityLower.Contains("4k") ? "BluRay 2160p REMUX x265" : "BluRay REMUX";
|
2020-04-25 01:33:13 +00:00
|
|
|
else if (qualityLower.Contains("4k")) // filter full and remux before 4k (there are 4k full and remux)
|
2020-05-05 22:46:31 +00:00
|
|
|
fixedQuality = "BluRay 2160p x265";
|
2020-04-25 01:33:13 +00:00
|
|
|
else if (qualityLower.Contains("microhd"))
|
2020-05-05 22:46:31 +00:00
|
|
|
fixedQuality = qualityLower.Contains("720") ? "BluRay 720p MicroHD" : "BluRay 1080p MicroHD";
|
2020-04-25 01:33:13 +00:00
|
|
|
else if (qualityLower.Contains("blurayrip"))
|
|
|
|
fixedQuality = "BluRay 720p";
|
2020-05-05 22:46:31 +00:00
|
|
|
else if (qualityLower.Contains("dvdrip"))
|
|
|
|
fixedQuality = "DVDRip";
|
2020-04-25 01:33:13 +00:00
|
|
|
else if (qualityLower.Contains("htdv"))
|
|
|
|
fixedQuality = "HDTV";
|
2020-05-05 22:46:31 +00:00
|
|
|
// BluRay and DVD Screener are not supported in Radarr
|
|
|
|
else if (qualityLower.Contains("screener") || qualityLower.Contains("screeener"))
|
|
|
|
{
|
|
|
|
if (qualityLower.Contains("720p") || qualityLower.Contains("dvd"))
|
|
|
|
fixedQuality = "Screener 720p";
|
|
|
|
else if (qualityLower.Contains("bluray")) // there are bluray with 720p (condition after 720p)
|
|
|
|
fixedQuality = "Screener 1080p";
|
|
|
|
else
|
|
|
|
fixedQuality = "TS Screener";
|
|
|
|
}
|
2020-04-25 01:33:13 +00:00
|
|
|
|
2020-05-05 22:46:31 +00:00
|
|
|
return $"{release.Title} {fixedLanguage} {fixedQuality}";
|
2018-07-02 10:56:53 +00:00
|
|
|
}
|
2019-08-18 20:53:14 +00:00
|
|
|
|
|
|
|
private string RemoveDiacritics(string text)
|
|
|
|
{
|
|
|
|
var normalizedString = text.Normalize(NormalizationForm.FormD);
|
2020-03-26 22:15:28 +00:00
|
|
|
|
|
|
|
// https://stackoverflow.com/a/14812065/9719178
|
|
|
|
// TODO Better performance version in .Net-Core:
|
|
|
|
// return string.Concat(normalizedString.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark))
|
|
|
|
// .Normalize(NormalizationForm.FormC);
|
|
|
|
|
2019-08-18 20:53:14 +00:00
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var c in normalizedString)
|
|
|
|
{
|
|
|
|
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
|
|
|
|
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
|
|
|
|
stringBuilder.Append(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
|
|
|
|
}
|
2018-05-12 01:55:24 +00:00
|
|
|
}
|
|
|
|
}
|