2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2020-01-06 22:41:51 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Net;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
using AngleSharp.Html.Parser;
|
|
|
|
using Jackett.Common.Models;
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
|
|
|
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
|
2020-02-09 18:08:34 +00:00
|
|
|
using WebClient = Jackett.Common.Utils.Clients.WebClient;
|
2020-01-06 22:41:51 +00:00
|
|
|
|
|
|
|
namespace Jackett.Common.Indexers
|
|
|
|
{
|
2020-01-11 07:08:18 +00:00
|
|
|
// ReSharper disable once UnusedType.Global
|
2020-01-06 22:41:51 +00:00
|
|
|
public class DivxTotal : BaseWebIndexer
|
|
|
|
{
|
2020-01-11 07:08:18 +00:00
|
|
|
private const int MaxResultsPerPage = 15;
|
|
|
|
private const int MaxSearchPageLimit = 3;
|
2020-01-11 07:48:12 +00:00
|
|
|
private static class DivxTotalCategories
|
|
|
|
{
|
|
|
|
public static string Peliculas => "peliculas";
|
|
|
|
public static string PeliculasHd => "peliculas-hd";
|
|
|
|
public static string Peliculas3D => "peliculas-3-d";
|
|
|
|
public static string PeliculasDvdr => "peliculas-dvdr";
|
|
|
|
public static string Series => "series";
|
|
|
|
public static string Programas => "programas";
|
|
|
|
public static string Otros => "otros";
|
|
|
|
}
|
|
|
|
private static class DivxTotalFizeSizes
|
|
|
|
{
|
|
|
|
public static long Peliculas => 2147483648; // 2 GB
|
|
|
|
public static long PeliculasDvdr => 5368709120; // 5 GB
|
|
|
|
public static long Series => 524288000; // 500 MB
|
|
|
|
public static long Otros => 524288000; // 500 MB
|
|
|
|
}
|
2020-01-06 22:41:51 +00:00
|
|
|
|
|
|
|
public DivxTotal(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
|
|
|
|
: base(name: "DivxTotal",
|
|
|
|
description: "DivxTotal is a SPANISH site for Movies, TV series and Software",
|
|
|
|
link: "https://www.divxtotal.la/",
|
|
|
|
caps: new TorznabCapabilities(),
|
|
|
|
configService: configService,
|
|
|
|
client: w,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
|
|
|
configData: new ConfigurationData())
|
|
|
|
{
|
|
|
|
Encoding = Encoding.UTF8;
|
|
|
|
Language = "es-es";
|
|
|
|
Type = "public";
|
|
|
|
|
|
|
|
var matchWords = new BoolItem() { Name = "Match words in title", Value = true };
|
|
|
|
configData.AddDynamic("MatchWords", matchWords);
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
AddCategoryMapping(DivxTotalCategories.Peliculas, TorznabCatType.MoviesSD);
|
|
|
|
AddCategoryMapping(DivxTotalCategories.PeliculasHd, TorznabCatType.MoviesSD);
|
|
|
|
AddCategoryMapping(DivxTotalCategories.Peliculas3D, TorznabCatType.MoviesHD);
|
|
|
|
AddCategoryMapping(DivxTotalCategories.PeliculasDvdr, TorznabCatType.MoviesDVD);
|
|
|
|
AddCategoryMapping(DivxTotalCategories.Series, TorznabCatType.TVSD);
|
|
|
|
AddCategoryMapping(DivxTotalCategories.Programas, TorznabCatType.PC);
|
|
|
|
AddCategoryMapping(DivxTotalCategories.Otros, TorznabCatType.OtherMisc);
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
|
|
|
{
|
|
|
|
configData.LoadValuesFromJson(configJson);
|
|
|
|
var releases = await PerformQuery(new TorznabQuery());
|
|
|
|
|
|
|
|
await ConfigureIfOK(string.Empty, releases.Any(), () =>
|
2020-01-11 07:08:18 +00:00
|
|
|
throw new Exception("Could not find releases from this URL"));
|
2020-01-06 22:41:51 +00:00
|
|
|
|
|
|
|
return IndexerConfigurationStatus.Completed;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
|
|
|
var matchWords = ((BoolItem)configData.GetDynamic("MatchWords")).Value;
|
2020-01-11 07:48:12 +00:00
|
|
|
matchWords = query.SearchTerm != "" && matchWords;
|
2020-01-06 22:41:51 +00:00
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
// we remove parts from the original query
|
|
|
|
query = ParseQuery(query);
|
2020-02-09 02:35:16 +00:00
|
|
|
var qc = new NameValueCollection { { "s", query.SearchTerm } };
|
2020-01-06 22:41:51 +00:00
|
|
|
|
|
|
|
var page = 1;
|
|
|
|
var isLastPage = false;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
var url = SiteLink + "page/" + page + "/?" + qc.GetQueryString();
|
|
|
|
var result = await RequestStringWithCookies(url);
|
|
|
|
|
|
|
|
if (result.Status != HttpStatusCode.OK)
|
|
|
|
throw new ExceptionWithConfigData(result.Content, configData);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var searchResultParser = new HtmlParser();
|
|
|
|
var doc = searchResultParser.ParseDocument(result.Content);
|
|
|
|
|
|
|
|
var table = doc.QuerySelector("table.table");
|
2020-01-11 07:08:18 +00:00
|
|
|
if (table == null)
|
|
|
|
break;
|
2020-01-06 22:41:51 +00:00
|
|
|
var rows = table.QuerySelectorAll("tr");
|
2020-02-09 02:35:16 +00:00
|
|
|
isLastPage = rows.Length - 1 <= MaxResultsPerPage; // rows includes the header
|
2020-01-06 22:41:51 +00:00
|
|
|
var isHeader = true;
|
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
2020-02-09 02:35:16 +00:00
|
|
|
if (isHeader)
|
|
|
|
{
|
2020-01-06 22:41:51 +00:00
|
|
|
isHeader = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-03-01 19:01:59 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
await ParseRelease(releases, row, query, matchWords);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
logger.Error($"CardigannIndexer ({ID}): Error while parsing row '{row.ToHtmlPretty()}':\n\n{ex}");
|
|
|
|
}
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(result.Content, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
page++; // update page number
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
} while (!isLastPage && page <= MaxSearchPageLimit);
|
2020-01-06 22:41:51 +00:00
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<byte[]> Download(Uri link)
|
|
|
|
{
|
|
|
|
// for tv series we already have the link
|
|
|
|
var downloadUrl = link.ToString();
|
|
|
|
// for other categories we have to do another step
|
|
|
|
if (!downloadUrl.EndsWith(".torrent"))
|
|
|
|
{
|
|
|
|
var result = await RequestStringWithCookies(downloadUrl);
|
|
|
|
|
|
|
|
if (result.Status != HttpStatusCode.OK)
|
|
|
|
throw new ExceptionWithConfigData(result.Content, configData);
|
|
|
|
|
|
|
|
var searchResultParser = new HtmlParser();
|
|
|
|
var doc = searchResultParser.ParseDocument(result.Content);
|
|
|
|
|
2020-03-01 19:01:59 +00:00
|
|
|
var onclick = doc.QuerySelector("a[onclick*=\"/download/torrent\"]")
|
2020-01-06 22:41:51 +00:00
|
|
|
.GetAttribute("onclick");
|
|
|
|
downloadUrl = OnclickToDownloadLink(onclick);
|
|
|
|
}
|
|
|
|
|
|
|
|
var content = await base.Download(new Uri(downloadUrl));
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
|
|
|
|
private async Task ParseRelease(ICollection<ReleaseInfo> releases, IParentNode row, TorznabQuery query,
|
|
|
|
bool matchWords)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
|
|
|
var anchor = row.QuerySelector("a");
|
|
|
|
var commentsLink = anchor.GetAttribute("href");
|
|
|
|
var title = anchor.TextContent.Trim();
|
|
|
|
var cat = commentsLink.Split('/')[3];
|
|
|
|
var categories = MapTrackerCatToNewznab(cat);
|
|
|
|
var publishStr = row.QuerySelectorAll("td")[2].TextContent.Trim();
|
|
|
|
var publishDate = TryToParseDate(publishStr, DateTime.Now);
|
|
|
|
var sizeStr = row.QuerySelectorAll("td")[3].TextContent.Trim();
|
|
|
|
|
|
|
|
// return results only for requested categories
|
2020-01-11 07:48:12 +00:00
|
|
|
if (query.Categories.Any() && !query.Categories.Contains(categories.First()))
|
2020-01-06 22:41:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// match the words in the query with the titles
|
2020-01-11 07:48:12 +00:00
|
|
|
if (matchWords && !CheckTitleMatchWords(query.SearchTerm, title))
|
2020-01-06 22:41:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// parsing is different for each category
|
2020-01-11 07:48:12 +00:00
|
|
|
if (cat == DivxTotalCategories.Series)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
2020-01-11 07:48:12 +00:00
|
|
|
await ParseSeriesRelease(releases, query, commentsLink, cat, publishDate);
|
2020-02-09 02:35:16 +00:00
|
|
|
}
|
|
|
|
else if (query.Episode == null) // if it's scene series, we don't return other categories
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
2020-01-11 07:48:12 +00:00
|
|
|
if (cat == DivxTotalCategories.Peliculas || cat == DivxTotalCategories.PeliculasHd ||
|
|
|
|
cat == DivxTotalCategories.Peliculas3D || cat == DivxTotalCategories.PeliculasDvdr)
|
|
|
|
ParseMovieRelease(releases, query, title, commentsLink, cat, publishDate, sizeStr);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var size = TryToParseSize(sizeStr, DivxTotalFizeSizes.Otros);
|
|
|
|
GenerateRelease(releases, title, commentsLink, commentsLink, cat, publishDate, size);
|
|
|
|
}
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
private async Task ParseSeriesRelease(ICollection<ReleaseInfo> releases, TorznabQuery query,
|
|
|
|
string commentsLink, string cat, DateTime publishDate)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
|
|
|
var result = await RequestStringWithCookies(commentsLink);
|
|
|
|
|
|
|
|
if (result.Status != HttpStatusCode.OK)
|
|
|
|
throw new ExceptionWithConfigData(result.Content, configData);
|
|
|
|
|
|
|
|
var searchResultParser = new HtmlParser();
|
|
|
|
var doc = searchResultParser.ParseDocument(result.Content);
|
|
|
|
|
|
|
|
var tables = doc.QuerySelectorAll("table.table");
|
|
|
|
foreach (var table in tables)
|
|
|
|
{
|
|
|
|
var rows = table.QuerySelectorAll("tr");
|
|
|
|
var isHeader = true;
|
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
2020-02-09 02:35:16 +00:00
|
|
|
if (isHeader)
|
|
|
|
{
|
2020-01-06 22:41:51 +00:00
|
|
|
isHeader = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var anchor = row.QuerySelector("a");
|
|
|
|
var episodeTitle = anchor.TextContent.Trim();
|
|
|
|
var onclick = anchor.GetAttribute("onclick");
|
|
|
|
var downloadLink = OnclickToDownloadLink(onclick);
|
|
|
|
var episodePublishStr = row.QuerySelectorAll("td")[3].TextContent.Trim();
|
|
|
|
var episodePublish = TryToParseDate(episodePublishStr, publishDate);
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
// Convert the title to Scene format
|
|
|
|
episodeTitle = ParseDivxTotalSeriesTitle(episodeTitle, query);
|
|
|
|
|
|
|
|
// if the original query was in scene format, we filter the results to match episode
|
|
|
|
// query.Episode != null means scene title
|
|
|
|
if (query.Episode != null && !episodeTitle.Contains(query.GetEpisodeSearchString()))
|
|
|
|
continue;
|
2020-01-06 22:41:51 +00:00
|
|
|
|
|
|
|
GenerateRelease(releases, episodeTitle, commentsLink, downloadLink, cat, episodePublish,
|
2020-01-11 07:48:12 +00:00
|
|
|
DivxTotalFizeSizes.Series);
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
private void ParseMovieRelease(ICollection<ReleaseInfo> releases, TorznabQuery query, string title,
|
|
|
|
string commentsLink, string cat, DateTime publishDate, string sizeStr)
|
|
|
|
{
|
|
|
|
// parse tags in title, we need to put the year after the real title (before the tags)
|
|
|
|
// La Maldicion ( HD-CAM)
|
|
|
|
// Mascotas 2 4K (1080p) (DUAL)
|
|
|
|
// Dragon Ball Super: Broly [2018] [DVD9] [PAL] [Español]
|
|
|
|
var tags = "";
|
|
|
|
var queryMatches = Regex.Matches(title, @"[\[\(]([^\]\)]+)[\]\)]", RegexOptions.IgnoreCase);
|
|
|
|
foreach (Match m in queryMatches)
|
|
|
|
{
|
|
|
|
tags += " " + m.Groups[1].Value.Trim();
|
|
|
|
title = title.Replace(m.Groups[0].Value, "");
|
|
|
|
}
|
|
|
|
title = title.Trim();
|
|
|
|
title = Regex.Replace(title, " 4K$", "", RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
// add the year
|
|
|
|
title = query.Year != null ? title + " " + query.Year : title;
|
|
|
|
|
|
|
|
// add the tags
|
|
|
|
title += tags.ToUpper();
|
|
|
|
|
|
|
|
// add suffix and calculate the size
|
|
|
|
var size = TryToParseSize(sizeStr, DivxTotalFizeSizes.Peliculas);
|
|
|
|
if (cat == DivxTotalCategories.Peliculas)
|
|
|
|
title += " SPANISH DVDRip XviD";
|
|
|
|
else if (cat == DivxTotalCategories.PeliculasHd || cat == DivxTotalCategories.Peliculas3D)
|
|
|
|
title += " SPANISH BDRip x264";
|
|
|
|
else if (cat == DivxTotalCategories.PeliculasDvdr)
|
|
|
|
{
|
2020-02-09 02:35:16 +00:00
|
|
|
title += " SPANISH DVDR";
|
|
|
|
size = TryToParseSize(sizeStr, DivxTotalFizeSizes.PeliculasDvdr);
|
2020-01-11 07:48:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new Exception("Unknown category " + cat);
|
|
|
|
|
|
|
|
GenerateRelease(releases, title, commentsLink, commentsLink, cat, publishDate, size);
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
private void GenerateRelease(ICollection<ReleaseInfo> releases, string title, string commentsLink,
|
|
|
|
string downloadLink, string cat, DateTime publishDate, long size)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
2020-01-11 07:08:18 +00:00
|
|
|
// ReSharper disable once UseObjectOrCollectionInitializer
|
2020-01-06 22:41:51 +00:00
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
release.Title = title;
|
2020-01-06 22:41:51 +00:00
|
|
|
release.Comments = new Uri(commentsLink);
|
|
|
|
release.Link = new Uri(downloadLink);
|
|
|
|
release.Guid = release.Link;
|
|
|
|
|
|
|
|
release.Category = MapTrackerCatToNewznab(cat);
|
|
|
|
release.PublishDate = publishDate;
|
|
|
|
release.Size = size;
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
release.Files = 1;
|
|
|
|
|
2020-01-06 22:41:51 +00:00
|
|
|
release.Seeders = 1;
|
|
|
|
release.Peers = 2;
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
release.MinimumRatio = 1;
|
2020-01-11 18:07:19 +00:00
|
|
|
release.MinimumSeedTime = 172800; // 48 hours
|
2020-01-06 22:41:51 +00:00
|
|
|
release.DownloadVolumeFactor = 0;
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
private static string OnclickToDownloadLink(string onclick)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
2020-01-11 07:08:18 +00:00
|
|
|
// onclick="post('/download/torrent.php', {u: 'aHR0cHM6Ly93d3cuZGl2eHRvdGF='});"
|
2020-01-06 22:41:51 +00:00
|
|
|
var base64EncodedData = onclick.Split('\'')[3];
|
|
|
|
var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
|
|
|
|
return Encoding.UTF8.GetString(base64EncodedBytes);
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
private static bool CheckTitleMatchWords(string queryStr, string title)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
|
|
|
// this code split the words, remove words with 2 letters or less, remove accents and lowercase
|
2020-01-11 07:08:18 +00:00
|
|
|
var queryMatches = Regex.Matches(queryStr, @"\b[\w']*\b");
|
2020-01-06 22:41:51 +00:00
|
|
|
var queryWords = from m in queryMatches.Cast<Match>()
|
2020-02-09 02:35:16 +00:00
|
|
|
where !string.IsNullOrEmpty(m.Value) && m.Value.Length > 2
|
|
|
|
select Encoding.UTF8.GetString(Encoding.GetEncoding("ISO-8859-8").GetBytes(m.Value.ToLower()));
|
2020-01-06 22:41:51 +00:00
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
var titleMatches = Regex.Matches(title, @"\b[\w']*\b");
|
2020-01-06 22:41:51 +00:00
|
|
|
var titleWords = from m in titleMatches.Cast<Match>()
|
2020-02-09 02:35:16 +00:00
|
|
|
where !string.IsNullOrEmpty(m.Value) && m.Value.Length > 2
|
|
|
|
select Encoding.UTF8.GetString(Encoding.GetEncoding("ISO-8859-8").GetBytes(m.Value.ToLower()));
|
2020-01-06 22:41:51 +00:00
|
|
|
titleWords = titleWords.ToArray();
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
return queryWords.All(word => titleWords.Contains(word));
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
|
2020-01-11 07:48:12 +00:00
|
|
|
private static TorznabQuery ParseQuery(TorznabQuery query)
|
|
|
|
{
|
|
|
|
// Eg. Marco.Polo.2014.S02E08
|
|
|
|
|
|
|
|
// the season/episode part is already parsed by Jackett
|
|
|
|
// query.SanitizedSearchTerm = Marco.Polo.2014.
|
|
|
|
// query.Season = 2
|
|
|
|
// query.Episode = 8
|
|
|
|
var searchTerm = query.SanitizedSearchTerm;
|
|
|
|
|
|
|
|
// replace punctuation symbols with spaces
|
|
|
|
// searchTerm = Marco Polo 2014
|
|
|
|
searchTerm = Regex.Replace(searchTerm, @"[-._\(\)@/\\\[\]\+\%]", " ");
|
|
|
|
searchTerm = Regex.Replace(searchTerm, @"\s+", " ");
|
|
|
|
searchTerm = searchTerm.Trim();
|
|
|
|
|
|
|
|
// we parse the year and remove it from search
|
|
|
|
// searchTerm = Marco Polo
|
|
|
|
// query.Year = 2014
|
|
|
|
var r = new Regex("([ ]+([0-9]{4}))$", RegexOptions.IgnoreCase);
|
|
|
|
var m = r.Match(searchTerm);
|
|
|
|
if (m.Success)
|
|
|
|
{
|
|
|
|
query.Year = int.Parse(m.Groups[2].Value);
|
|
|
|
searchTerm = searchTerm.Replace(m.Groups[1].Value, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove some words
|
|
|
|
searchTerm = Regex.Replace(searchTerm, @"\b(espa[ñn]ol|spanish|castellano|spa)\b", "", RegexOptions.IgnoreCase);
|
|
|
|
|
|
|
|
query.SearchTerm = searchTerm;
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string ParseDivxTotalSeriesTitle(string episodeTitle, TorznabQuery query)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
2020-01-11 07:48:12 +00:00
|
|
|
// episodeTitle = American Horror Story6x04
|
2020-01-06 22:41:51 +00:00
|
|
|
var newTitle = episodeTitle;
|
|
|
|
try
|
|
|
|
{
|
2020-01-11 07:48:12 +00:00
|
|
|
var r = new Regex("(([0-9]+)x([0-9]+)[^0-9]*)$", RegexOptions.IgnoreCase);
|
2020-01-11 07:08:18 +00:00
|
|
|
var m = r.Match(newTitle);
|
2020-01-06 22:41:51 +00:00
|
|
|
if (m.Success)
|
|
|
|
{
|
|
|
|
var season = "S" + m.Groups[2].Value.PadLeft(2, '0');
|
|
|
|
var episode = "E" + m.Groups[3].Value.PadLeft(2, '0');
|
2020-01-11 07:48:12 +00:00
|
|
|
// if the original query was in scene format, we have to put the year back
|
|
|
|
// query.Episode != null means scene title
|
|
|
|
var year = query.Episode != null && query.Year != null ? " " + query.Year : "";
|
|
|
|
newTitle = newTitle.Replace(m.Groups[1].Value, year + " " + season + episode);
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e);
|
|
|
|
throw;
|
|
|
|
}
|
2020-01-11 07:48:12 +00:00
|
|
|
newTitle += " SPANISH SDTV XviD";
|
|
|
|
// return American Horror Story S06E04 SPANISH SDTV XviD
|
2020-01-06 22:41:51 +00:00
|
|
|
return newTitle;
|
|
|
|
}
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
private static DateTime TryToParseDate(string dateToParse, DateTime dateDefault)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-01-11 07:08:18 +00:00
|
|
|
return DateTime.ParseExact(dateToParse, "dd-MM-yyyy", CultureInfo.InvariantCulture);
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
// ignored
|
|
|
|
}
|
2020-01-11 07:08:18 +00:00
|
|
|
return dateDefault;
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
|
2020-01-11 07:08:18 +00:00
|
|
|
private static long TryToParseSize(string sizeToParse, long sizeDefault)
|
2020-01-06 22:41:51 +00:00
|
|
|
{
|
|
|
|
try
|
2020-02-09 02:35:16 +00:00
|
|
|
{
|
2020-01-11 07:08:18 +00:00
|
|
|
return ReleaseInfo.GetBytes(sizeToParse);
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
// ignored
|
|
|
|
}
|
2020-01-11 07:08:18 +00:00
|
|
|
return sizeDefault;
|
2020-01-06 22:41:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|