2017-10-29 06:21:18 +00:00
|
|
|
|
using System;
|
2016-10-29 20:14:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
using System.Collections.Specialized;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using System.Globalization;
|
2017-11-20 14:27:25 +00:00
|
|
|
|
using System.Linq;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using System.Text;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using AngleSharp.Dom;
|
2019-01-20 00:09:27 +00:00
|
|
|
|
using AngleSharp.Html.Parser;
|
2018-03-10 08:05:56 +00:00
|
|
|
|
using Jackett.Common.Models;
|
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
|
using Jackett.Common.Utils.Clients;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NLog;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
|
namespace Jackett.Common.Indexers
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
|
public class BJShare : BaseWebIndexer
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
private string LoginUrl => SiteLink + "login.php";
|
|
|
|
|
private string BrowseUrl => SiteLink + "torrents.php";
|
|
|
|
|
private string TodayUrl => SiteLink + "torrents.php?action=today";
|
|
|
|
|
private readonly char[] _digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
|
|
|
|
private readonly Dictionary<string, string> _commonSearchTerms = new Dictionary<string, string>
|
|
|
|
|
{
|
2018-12-20 14:57:41 +00:00
|
|
|
|
{ "agents of shield", "Agents of S.H.I.E.L.D."},
|
2019-12-27 20:04:43 +00:00
|
|
|
|
{ "tell me a story us", "Tell Me a Story"},
|
|
|
|
|
{ "greys anatomy", "grey's anatomy"}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<string, string> _commonResultTerms = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "tell me a story", "Tell Me a Story US"},
|
|
|
|
|
{ "fairy tail: final season", "Fairy Tail: Final Series"},
|
|
|
|
|
{ "agents of s.h.i.e.l.d.", "Marvels Agents of SHIELD"},
|
|
|
|
|
{ "legends of tomorrow", "DCs Legends of Tomorrow"}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly List<string> _absoluteNumbering = new List<string>
|
|
|
|
|
{
|
|
|
|
|
"One Piece", "Boruto", "Black Clover", "Fairy Tail", "Super Dragon Ball Heroes"
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-12 19:44:42 +00:00
|
|
|
|
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
|
|
|
|
|
"https://bj-share.me/"
|
|
|
|
|
};
|
2016-10-29 20:14:38 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
private ConfigurationDataBasicLoginWithRSSAndDisplay ConfigData
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
get => (ConfigurationDataBasicLoginWithRSSAndDisplay)configData;
|
|
|
|
|
set => configData = value;
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
|
public BJShare(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2018-05-20 19:07:00 +00:00
|
|
|
|
: base("BJ-Share",
|
2016-10-29 20:14:38 +00:00
|
|
|
|
description: "A brazilian tracker.",
|
2018-06-12 19:44:42 +00:00
|
|
|
|
link: "https://bj-share.info/",
|
2016-10-29 20:14:38 +00:00
|
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
2017-07-10 20:58:44 +00:00
|
|
|
|
configService: configService,
|
2016-10-29 20:14:38 +00:00
|
|
|
|
client: wc,
|
|
|
|
|
logger: l,
|
|
|
|
|
p: ps,
|
|
|
|
|
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay())
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2018-04-06 13:16:04 +00:00
|
|
|
|
Encoding = Encoding.UTF8;
|
2016-12-09 17:20:58 +00:00
|
|
|
|
Language = "pt-br";
|
2017-01-27 15:57:32 +00:00
|
|
|
|
Type = "private";
|
2016-12-06 13:56:47 +00:00
|
|
|
|
|
2019-05-11 03:27:25 +00:00
|
|
|
|
TorznabCaps.SupportsImdbMovieSearch = true;
|
2018-12-01 11:37:41 +00:00
|
|
|
|
|
2018-06-29 12:16:41 +00:00
|
|
|
|
AddCategoryMapping(14, TorznabCatType.TVAnime, "Anime");
|
|
|
|
|
AddCategoryMapping(3, TorznabCatType.PC0day, "Aplicativos");
|
|
|
|
|
AddCategoryMapping(8, TorznabCatType.Other, "Apostilas/Tutoriais");
|
|
|
|
|
AddCategoryMapping(19, TorznabCatType.AudioAudiobook, "Audiobook");
|
|
|
|
|
AddCategoryMapping(16, TorznabCatType.TVOTHER, "Desenho Animado");
|
|
|
|
|
AddCategoryMapping(18, TorznabCatType.TVDocumentary, "Documentários");
|
|
|
|
|
AddCategoryMapping(10, TorznabCatType.Books, "E-Books");
|
|
|
|
|
AddCategoryMapping(20, TorznabCatType.TVSport, "Esportes");
|
|
|
|
|
AddCategoryMapping(1, TorznabCatType.Movies, "Filmes");
|
|
|
|
|
AddCategoryMapping(12, TorznabCatType.MoviesOther, "Histórias em Quadrinhos");
|
|
|
|
|
AddCategoryMapping(5, TorznabCatType.Audio, "Músicas");
|
|
|
|
|
AddCategoryMapping(7, TorznabCatType.Other, "Outros");
|
|
|
|
|
AddCategoryMapping(9, TorznabCatType.BooksMagazines, "Revistas");
|
|
|
|
|
AddCategoryMapping(2, TorznabCatType.TV, "Seriados");
|
|
|
|
|
AddCategoryMapping(17, TorznabCatType.TV, "Shows");
|
|
|
|
|
AddCategoryMapping(13, TorznabCatType.TV, "Stand Up Comedy");
|
|
|
|
|
AddCategoryMapping(11, TorznabCatType.Other, "Video-Aula");
|
|
|
|
|
AddCategoryMapping(6, TorznabCatType.TV, "Vídeos de TV");
|
|
|
|
|
AddCategoryMapping(4, TorznabCatType.Other, "Jogos");
|
|
|
|
|
AddCategoryMapping(199, TorznabCatType.XXX, "Filmes Adultos");
|
|
|
|
|
AddCategoryMapping(200, TorznabCatType.XXX, "Jogos Adultos");
|
|
|
|
|
AddCategoryMapping(201, TorznabCatType.XXXImageset, "Fotos Adultas");
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
|
LoadValuesFromJson(configJson);
|
2016-10-29 20:14:38 +00:00
|
|
|
|
|
|
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
{ "username", ConfigData.Username.Value },
|
|
|
|
|
{ "password", ConfigData.Password.Value },
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{ "keeplogged", "1" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl, true);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
|
|
|
|
{
|
|
|
|
|
var errorMessage = result.Content;
|
2018-05-20 19:07:00 +00:00
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, ConfigData);
|
2016-10-29 20:14:38 +00:00
|
|
|
|
});
|
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-07 03:21:03 +00:00
|
|
|
|
private string InternationalTitle(string title)
|
|
|
|
|
{
|
|
|
|
|
// Get international title if available, or use the full title if not
|
|
|
|
|
string cleanTitle = Regex.Replace(title, @".* \[(.*?)\](.*)", "$1$2");
|
|
|
|
|
cleanTitle = Regex.Replace(cleanTitle, @"(?:.*)\/(.*)", "$1");
|
|
|
|
|
|
|
|
|
|
return cleanTitle.Trim();
|
|
|
|
|
}
|
2017-11-20 14:27:25 +00:00
|
|
|
|
private string StripSearchString(string term, bool isAnime)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
|
|
|
|
// Search does not support searching with episode numbers so strip it if we have one
|
|
|
|
|
// Ww AND filter the result later to archive the proper result
|
2018-12-20 14:57:41 +00:00
|
|
|
|
term = Regex.Replace(term, @"[S|E]\d\d", string.Empty).Trim();
|
|
|
|
|
return isAnime ? term.TrimEnd(_digits) : term;
|
2018-05-20 19:07:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-27 20:04:43 +00:00
|
|
|
|
private bool IsAbsoluteNumbering(string title)
|
2018-05-20 19:07:00 +00:00
|
|
|
|
{
|
2019-12-27 20:04:43 +00:00
|
|
|
|
foreach (var absoluteTitle in _absoluteNumbering)
|
|
|
|
|
{
|
|
|
|
|
if (title.ToLower().Contains(absoluteTitle.ToLower()))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string FixAbsoluteNumbering(string title)
|
|
|
|
|
{
|
|
|
|
|
// if result is absolute numbered, convert title from SXXEXX to EXX
|
|
|
|
|
// Only few animes that i'm aware is in "absolute" numbering, the problem is that they include
|
2018-05-20 19:07:00 +00:00
|
|
|
|
// the season (wrong season) and episode as absolute, eg: One Piece - S08E836
|
|
|
|
|
// 836 is the latest episode in absolute numbering, that is correct, but S08 is not the current season...
|
|
|
|
|
// So for this show, i don't see a other way to make it work...
|
2019-10-15 19:35:07 +00:00
|
|
|
|
//
|
2018-05-20 19:07:00 +00:00
|
|
|
|
// All others animes that i tested is with correct season and episode set, so i can't remove the season from all
|
|
|
|
|
// or will break everything else
|
2019-10-15 19:35:07 +00:00
|
|
|
|
//
|
2018-05-20 19:07:00 +00:00
|
|
|
|
// In this indexer, it looks that it is added "automatically", so all current and new releases will be broken
|
|
|
|
|
// until they or the source from where they get that info fix it...
|
|
|
|
|
|
2019-12-27 20:04:43 +00:00
|
|
|
|
if (IsAbsoluteNumbering(title))
|
|
|
|
|
{
|
|
|
|
|
title = Regex.Replace(title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "");
|
|
|
|
|
return title;
|
2019-10-15 19:35:07 +00:00
|
|
|
|
}
|
|
|
|
|
else if (title.Contains("[Novela]"))
|
|
|
|
|
{
|
|
|
|
|
title = Regex.Replace(title, @"(Cap[\.]?[ ]?)", "S01E");
|
|
|
|
|
title = Regex.Replace(title, @"(\[Novela\]\ )", "");
|
|
|
|
|
title = Regex.Replace(title, @"(\ \-\s*Completo)", " - S01");
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return title;
|
|
|
|
|
}
|
2016-11-01 08:22:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2018-12-20 14:57:41 +00:00
|
|
|
|
query = query.Clone(); // avoid modifing the original query
|
2019-12-27 20:04:43 +00:00
|
|
|
|
|
2016-10-29 20:14:38 +00:00
|
|
|
|
var releases = new List<ReleaseInfo>();
|
2017-10-29 06:21:18 +00:00
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
// if the search string is empty use the "last 24h torrents" view
|
2018-12-01 11:37:41 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(query.SearchTerm) && !query.IsImdbQuery)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2016-10-29 20:14:38 +00:00
|
|
|
|
var results = await RequestStringWithCookies(TodayUrl);
|
2019-03-25 16:14:34 +00:00
|
|
|
|
if (results.IsRedirect)
|
|
|
|
|
{
|
|
|
|
|
// re-login
|
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
|
results = await RequestStringWithCookies(TodayUrl);
|
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
const string rowsSelector = "table.torrent_table > tbody > tr:not(tr.colhead)";
|
2016-10-29 20:14:38 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var searchResultParser = new HtmlParser();
|
2019-01-20 00:09:27 +00:00
|
|
|
|
var searchResultDocument = searchResultParser.ParseDocument(results.Content);
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var rows = searchResultDocument.QuerySelectorAll(rowsSelector);
|
|
|
|
|
foreach (var row in rows)
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2017-04-15 08:45:10 +00:00
|
|
|
|
try
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var release = new ReleaseInfo
|
|
|
|
|
{
|
|
|
|
|
MinimumRatio = 1,
|
|
|
|
|
MinimumSeedTime = 0
|
|
|
|
|
};
|
2016-10-29 20:14:38 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var qDetailsLink = row.QuerySelector("a.BJinfoBox");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
var qBJinfoBox = qDetailsLink.QuerySelector("span");
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var qCatLink = row.QuerySelector("a[href^=\"/torrents.php?filter_cat\"]");
|
|
|
|
|
var qDlLink = row.QuerySelector("a[href^=\"torrents.php?action=download\"]");
|
|
|
|
|
var qSeeders = row.QuerySelector("td:nth-child(4)");
|
|
|
|
|
var qLeechers = row.QuerySelector("td:nth-child(5)");
|
|
|
|
|
var qQuality = row.QuerySelector("font[color=\"red\"]");
|
|
|
|
|
var qFreeLeech = row.QuerySelector("font[color=\"green\"]:contains(Free)");
|
|
|
|
|
var qTitle = qDetailsLink.QuerySelector("font");
|
|
|
|
|
// Get international title if available, or use the full title if not
|
|
|
|
|
release.Title = Regex.Replace(qTitle.TextContent, @".* \[(.*?)\](.*)", "$1$2");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2019-10-12 06:58:16 +00:00
|
|
|
|
var year = "";
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.Description = "";
|
2018-05-20 19:07:00 +00:00
|
|
|
|
foreach (var child in qBJinfoBox.ChildNodes)
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var type = child.NodeType;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
if (type != NodeType.Text)
|
|
|
|
|
continue;
|
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var line = child.TextContent;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
if (line.StartsWith("Tamanho:"))
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var size = line.Substring("Tamanho: ".Length); ;
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(size);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
else if (line.StartsWith("Lançado em: "))
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var publishDateStr = line.Substring("Lançado em: ".Length).Replace("às ", "");
|
|
|
|
|
publishDateStr += " +0";
|
|
|
|
|
var publishDate = DateTime.SpecifyKind(DateTime.ParseExact(publishDateStr, "dd/MM/yyyy HH:mm z", CultureInfo.InvariantCulture), DateTimeKind.Unspecified);
|
|
|
|
|
release.PublishDate = publishDate.ToLocalTime();
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
2019-10-12 06:58:16 +00:00
|
|
|
|
else if (line.StartsWith("Ano:"))
|
|
|
|
|
{
|
|
|
|
|
year = line.Substring("Ano: ".Length); ;
|
|
|
|
|
|
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
release.Description += line + "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var catStr = qCatLink.GetAttribute("href").Split('=')[1];
|
2018-05-20 19:07:00 +00:00
|
|
|
|
release.Title = FixAbsoluteNumbering(release.Title);
|
|
|
|
|
|
2019-10-12 06:58:16 +00:00
|
|
|
|
if(year != "")
|
|
|
|
|
{
|
|
|
|
|
release.Title += " " + year;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-12 17:11:58 +00:00
|
|
|
|
if (qQuality != null)
|
2017-11-20 14:27:25 +00:00
|
|
|
|
{
|
2019-03-12 17:11:58 +00:00
|
|
|
|
var quality = qQuality.TextContent;
|
2019-11-07 03:21:03 +00:00
|
|
|
|
|
2019-03-12 17:11:58 +00:00
|
|
|
|
switch (quality)
|
|
|
|
|
{
|
|
|
|
|
case "Full HD":
|
|
|
|
|
release.Title += " 1080p";
|
|
|
|
|
break;
|
|
|
|
|
case "HD":
|
|
|
|
|
release.Title += " 720p";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
release.Title += " 480p";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-11-20 14:27:25 +00:00
|
|
|
|
}
|
2018-04-06 13:16:04 +00:00
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.Category = MapTrackerCatToNewznab(catStr);
|
2018-05-20 19:07:00 +00:00
|
|
|
|
release.Link = new Uri(SiteLink + qDlLink.GetAttribute("href"));
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
|
|
|
|
release.Guid = release.Link;
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(qSeeders.TextContent);
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(qLeechers.TextContent) + release.Seeders;
|
2018-05-20 19:07:00 +00:00
|
|
|
|
release.DownloadVolumeFactor = qFreeLeech != null ? 0 : 1;
|
2016-10-29 20:14:38 +00:00
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
releases.Add(release);
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
logger.Error($"{ID}: Error while parsing row '{row.OuterHtml}': {ex.Message}");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OnParseError(results.Content, ex);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
else // use search
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2017-04-15 08:45:10 +00:00
|
|
|
|
var searchUrl = BrowseUrl;
|
2017-11-20 14:27:25 +00:00
|
|
|
|
var isSearchAnime = query.Categories.Any(s => s == TorznabCatType.TVAnime.ID);
|
2018-05-20 19:07:00 +00:00
|
|
|
|
|
2018-12-01 11:37:41 +00:00
|
|
|
|
if (!query.IsImdbQuery)
|
2018-05-20 19:07:00 +00:00
|
|
|
|
{
|
2018-12-01 11:37:41 +00:00
|
|
|
|
foreach (var searchTerm in _commonSearchTerms)
|
|
|
|
|
{
|
|
|
|
|
query.SearchTerm = query.SearchTerm.ToLower().Replace(searchTerm.Key.ToLower(), searchTerm.Value);
|
|
|
|
|
}
|
2018-05-20 19:07:00 +00:00
|
|
|
|
}
|
2018-12-01 11:37:41 +00:00
|
|
|
|
|
2018-01-09 15:39:23 +00:00
|
|
|
|
var searchString = query.GetQueryString();
|
2018-12-01 11:37:41 +00:00
|
|
|
|
if (query.IsImdbQuery)
|
|
|
|
|
{
|
|
|
|
|
searchString = query.ImdbID;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-09 15:39:23 +00:00
|
|
|
|
var queryCollection = new NameValueCollection
|
|
|
|
|
{
|
|
|
|
|
{"searchstr", StripSearchString(searchString, isSearchAnime)},
|
|
|
|
|
{"order_by", "time"},
|
|
|
|
|
{"order_way", "desc"},
|
|
|
|
|
{"group_results", "1"},
|
|
|
|
|
{"action", "basic"},
|
|
|
|
|
{"searchsubmit", "1"}
|
|
|
|
|
};
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
|
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
|
{
|
2017-10-29 06:21:18 +00:00
|
|
|
|
queryCollection.Add("filter_cat[" + cat + "]", "1");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
|
|
|
|
|
2016-10-29 20:14:38 +00:00
|
|
|
|
var results = await RequestStringWithCookies(searchUrl);
|
2019-03-25 16:14:34 +00:00
|
|
|
|
if (results.IsRedirect)
|
|
|
|
|
{
|
|
|
|
|
// re-login
|
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
|
results = await RequestStringWithCookies(searchUrl);
|
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
const string rowsSelector = "table.torrent_table > tbody > tr:not(tr.colhead)";
|
2016-10-29 20:14:38 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var searchResultParser = new HtmlParser();
|
2019-01-20 00:09:27 +00:00
|
|
|
|
var searchResultDocument = searchResultParser.ParseDocument(results.Content);
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var rows = searchResultDocument.QuerySelectorAll(rowsSelector);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
ICollection<int> groupCategory = null;
|
|
|
|
|
string groupTitle = null;
|
|
|
|
|
string groupYearStr = null;
|
2018-05-23 13:40:23 +00:00
|
|
|
|
var categoryStr = "";
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
foreach (var row in rows)
|
2016-10-29 20:14:38 +00:00
|
|
|
|
{
|
2017-04-15 08:45:10 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]");
|
|
|
|
|
var title = qDetailsLink.TextContent;
|
|
|
|
|
ICollection<int> category = null;
|
|
|
|
|
string yearStr = null;
|
2019-10-15 19:35:07 +00:00
|
|
|
|
|
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
if (row.ClassList.Contains("group") || row.ClassList.Contains("torrent")) // group/ungrouped headers
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var qCatLink = row.QuerySelector("a[href^=\"/torrents.php?filter_cat\"]");
|
|
|
|
|
categoryStr = qCatLink.GetAttribute("href").Split('=')[1].Split('&')[0];
|
|
|
|
|
category = MapTrackerCatToNewznab(categoryStr);
|
2019-10-15 19:35:07 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
yearStr = qDetailsLink.NextSibling.TextContent.Trim().TrimStart('[').TrimEnd(']');
|
2017-11-20 14:27:25 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
title = FixAbsoluteNumbering(title);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
if (row.ClassList.Contains("group")) // group headers
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
groupCategory = category;
|
|
|
|
|
groupTitle = title;
|
|
|
|
|
groupYearStr = yearStr;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var release = new ReleaseInfo
|
|
|
|
|
{
|
|
|
|
|
MinimumRatio = 1,
|
|
|
|
|
MinimumSeedTime = 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var qDlLink = row.QuerySelector("a[href^=\"torrents.php?action=download\"]");
|
|
|
|
|
var qSize = row.QuerySelector("td:nth-last-child(4)");
|
|
|
|
|
var qGrabs = row.QuerySelector("td:nth-last-child(3)");
|
|
|
|
|
var qSeeders = row.QuerySelector("td:nth-last-child(2)");
|
|
|
|
|
var qLeechers = row.QuerySelector("td:nth-last-child(1)");
|
|
|
|
|
var qFreeLeech = row.QuerySelector("strong[title=\"Free\"]");
|
|
|
|
|
|
|
|
|
|
if (row.ClassList.Contains("group_torrent")) // torrents belonging to a group
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2018-05-23 13:40:23 +00:00
|
|
|
|
var description = Regex.Replace(qDetailsLink.TextContent.Trim(), @"\s+", " ");
|
|
|
|
|
description = Regex.Replace(description, @"((S\d{2})(E\d{2,4})?) (.*)", "$4");
|
|
|
|
|
release.Description = description;
|
2017-12-26 04:02:43 +00:00
|
|
|
|
|
2018-05-23 13:40:23 +00:00
|
|
|
|
var cleanTitle = Regex.Replace(groupTitle, @" - ((S(\d{2}))?E(\d{1,4}))", "");
|
2019-11-07 03:21:03 +00:00
|
|
|
|
// Get international title if available, or use the full title if not
|
|
|
|
|
cleanTitle = InternationalTitle(cleanTitle);
|
|
|
|
|
|
2019-12-27 20:04:43 +00:00
|
|
|
|
foreach (var resultTerm in _commonResultTerms)
|
|
|
|
|
{
|
|
|
|
|
var newTitle = cleanTitle.ToLower().Replace(resultTerm.Key.ToLower(), resultTerm.Value);
|
|
|
|
|
if (!string.Equals(newTitle, cleanTitle, StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
cleanTitle = newTitle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 13:40:23 +00:00
|
|
|
|
title = Regex.Replace(title.Trim(), @"\s+", " ");
|
|
|
|
|
var seasonEp = Regex.Replace(title, @"((S\d{2})?(E\d{2,4})?) .*", "$1");
|
2019-11-07 03:21:03 +00:00
|
|
|
|
if (seasonEp[0] == '[')
|
|
|
|
|
seasonEp = "";
|
2019-10-15 19:35:07 +00:00
|
|
|
|
|
2018-05-23 13:40:23 +00:00
|
|
|
|
// do not include year to animes
|
|
|
|
|
if (categoryStr == "14")
|
|
|
|
|
{
|
|
|
|
|
release.Title = cleanTitle + " " + seasonEp;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
release.Title = cleanTitle + " " + groupYearStr + " " + seasonEp;
|
|
|
|
|
}
|
2018-05-20 19:07:00 +00:00
|
|
|
|
release.Category = groupCategory;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
2018-05-20 19:07:00 +00:00
|
|
|
|
else if (row.ClassList.Contains("torrent")) // standalone/un grouped torrents
|
2017-04-15 08:45:10 +00:00
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var qDescription = row.QuerySelector("div.torrent_info");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.Description = qDescription.TextContent;
|
2019-10-15 19:35:07 +00:00
|
|
|
|
title = FixAbsoluteNumbering(title);
|
2017-12-26 04:02:43 +00:00
|
|
|
|
|
2018-05-23 13:40:23 +00:00
|
|
|
|
var cleanTitle = Regex.Replace(title, @" - ((S\d{2})?(E\d{2,4})?)", "");
|
2019-11-07 03:21:03 +00:00
|
|
|
|
// Get international title if available, or use the full title if not
|
|
|
|
|
cleanTitle = InternationalTitle(cleanTitle);
|
|
|
|
|
|
2019-12-27 20:04:43 +00:00
|
|
|
|
foreach (var resultTerm in _commonResultTerms)
|
|
|
|
|
{
|
|
|
|
|
var newTitle = cleanTitle.ToLower().Replace(resultTerm.Key.ToLower(), resultTerm.Value);
|
|
|
|
|
if (!string.Equals(newTitle, cleanTitle, StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
cleanTitle = newTitle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 13:40:23 +00:00
|
|
|
|
var seasonEp = Regex.Replace(title, @"^(.*?) - ((S\d{2})?(E\d{2,4})?)", "$2");
|
2019-11-07 03:21:03 +00:00
|
|
|
|
if (seasonEp[0] == '[')
|
|
|
|
|
seasonEp = "";
|
2018-05-23 13:40:23 +00:00
|
|
|
|
|
|
|
|
|
// do not include year to animes
|
|
|
|
|
if (categoryStr == "14")
|
|
|
|
|
{
|
|
|
|
|
release.Title = cleanTitle + " " + seasonEp;
|
|
|
|
|
}
|
2019-10-15 19:35:07 +00:00
|
|
|
|
// the seasonEp RegEx is getting all when done with movies, and then cleaning again when getting international name,
|
|
|
|
|
// so it was cutting of the year of movies and getting clonflict in Radarr
|
|
|
|
|
else if (categoryStr == "2" || categoryStr == "6")
|
2018-05-23 13:40:23 +00:00
|
|
|
|
{
|
|
|
|
|
release.Title = cleanTitle + " " + yearStr + " " + seasonEp;
|
|
|
|
|
}
|
2019-10-15 19:35:07 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
release.Title = cleanTitle + " " + yearStr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
release.Category = category;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
release.Description = release.Description.Replace(" / Free", ""); // Remove Free Tag
|
2017-04-20 08:22:45 +00:00
|
|
|
|
release.Description = release.Description.Replace("Full HD", "1080p");
|
2019-11-07 03:21:03 +00:00
|
|
|
|
// Handles HDR conflict
|
|
|
|
|
release.Description = release.Description.Replace("/ HD /", "/ 720p /");
|
|
|
|
|
release.Description = release.Description.Replace("/ HD]", "/ 720p]");
|
2017-04-20 08:22:45 +00:00
|
|
|
|
release.Description = release.Description.Replace("4K", "2160p");
|
2019-10-15 19:35:07 +00:00
|
|
|
|
release.Description = release.Description.Replace("SD", "480p");
|
2019-11-07 03:21:03 +00:00
|
|
|
|
release.Description = release.Description.Replace("Dual Áudio", "Dual");
|
|
|
|
|
// If it ain't nacional there will be the type of the audio / original audio
|
|
|
|
|
if(release.Description.IndexOf("Nacional") == -1)
|
|
|
|
|
{
|
|
|
|
|
release.Description = Regex.Replace(release.Description, @"(Dual|Legendado|Dublado) \/ (.*?) \/", "$1 /");
|
|
|
|
|
}
|
2019-10-15 19:35:07 +00:00
|
|
|
|
|
|
|
|
|
// Adjust the description in order to can be read by Radarr and Sonarr
|
|
|
|
|
|
|
|
|
|
var cleanDescription = release.Description.Trim().TrimStart('[').TrimEnd(']');
|
|
|
|
|
String[] titleElements;
|
2019-11-07 03:21:03 +00:00
|
|
|
|
|
|
|
|
|
//Formats the title so it can be parsed later
|
|
|
|
|
string[] stringSeparators = new string[] { " / " };
|
|
|
|
|
titleElements = cleanDescription.Split(stringSeparators, StringSplitOptions.None);
|
|
|
|
|
// release.Title += string.Join(" ", titleElements);
|
|
|
|
|
release.Title = release.Title.Trim();
|
|
|
|
|
|
|
|
|
|
release.Title += " " + titleElements[5] + " " + titleElements[3] + " " + titleElements[1] + " " + titleElements[2] + " " + titleElements[4] + " " + String.Join(" ", titleElements.Skip(6).Take(titleElements.Length - 6).ToArray());
|
2019-10-15 19:35:07 +00:00
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
// This tracker does not provide an publish date to search terms (only on last 24h page)
|
|
|
|
|
release.PublishDate = DateTime.Today;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
|
|
|
|
// check for previously stripped search terms
|
2018-12-01 11:37:41 +00:00
|
|
|
|
if (!query.IsImdbQuery && !query.MatchQueryStringAND(release.Title))
|
2017-04-15 08:45:10 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2018-05-20 19:07:00 +00:00
|
|
|
|
var size = qSize.TextContent;
|
|
|
|
|
release.Size = ReleaseInfo.GetBytes(size);
|
|
|
|
|
release.Link = new Uri(SiteLink + qDlLink.GetAttribute("href"));
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
|
|
|
|
release.Guid = release.Link;
|
2017-11-08 16:33:40 +00:00
|
|
|
|
release.Grabs = ParseUtil.CoerceLong(qGrabs.TextContent);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(qSeeders.TextContent);
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(qLeechers.TextContent) + release.Seeders;
|
2018-05-20 19:07:00 +00:00
|
|
|
|
release.DownloadVolumeFactor = qFreeLeech != null ? 0 : 1;
|
2016-10-29 20:14:38 +00:00
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
|
releases.Add(release);
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
|
logger.Error($"{ID}: Error while parsing row '{row.OuterHtml}': {ex.Message}");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OnParseError(results.Content, ex);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|