2020-02-09 02:35:16 +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;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
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
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
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";
|
2020-04-15 04:01:13 +00:00
|
|
|
private static readonly Regex _EpisodeRegex = new Regex(@"(?:[SsEe]\d{2,4}){1,2}");
|
2020-02-09 02:35:16 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
public override string[] LegacySiteLinks { get; protected set; } =
|
2019-12-27 20:04:43 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
"https://bj-share.me/"
|
2019-12-27 20:04:43 +00:00
|
|
|
};
|
2020-02-09 02:35:16 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
private ConfigurationDataBasicLoginWithRSSAndDisplay ConfigData => (ConfigurationDataBasicLoginWithRSSAndDisplay)configData;
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-27 20:04:43 +00:00
|
|
|
private readonly List<string> _absoluteNumbering = new List<string>
|
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
"One Piece",
|
|
|
|
"Boruto",
|
|
|
|
"Black Clover",
|
|
|
|
"Fairy Tail",
|
|
|
|
"Super Dragon Ball Heroes"
|
2019-12-27 20:04:43 +00:00
|
|
|
};
|
2020-02-09 02:35:16 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
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"}
|
2018-06-12 19:44:42 +00:00
|
|
|
};
|
2016-10-29 20:14:38 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
private readonly Dictionary<string, string> _commonSearchTerms = new Dictionary<string, string>
|
2016-10-29 20:14:38 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
{"agents of shield", "Agents of S.H.I.E.L.D."},
|
|
|
|
{"tell me a story us", "Tell Me a Story"},
|
|
|
|
{"greys anatomy", "grey's anatomy"}
|
|
|
|
};
|
2016-10-29 20:14:38 +00:00
|
|
|
|
2020-05-11 19:59:28 +00:00
|
|
|
public BJShare(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
|
|
|
: base(id: "bjshare",
|
|
|
|
name: "BJ-Share",
|
|
|
|
description: "A brazilian tracker.",
|
|
|
|
link: "https://bj-share.info/",
|
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
|
|
|
SupportsImdbMovieSearch = true
|
|
|
|
},
|
|
|
|
configService: configService,
|
|
|
|
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
|
|
|
|
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");
|
2020-03-01 19:05:17 +00:00
|
|
|
AddCategoryMapping(4, TorznabCatType.PCGames, "Jogos");
|
2018-06-29 12:16:41 +00:00
|
|
|
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>
|
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
{"username", ConfigData.Username.Value},
|
|
|
|
{"password", ConfigData.Password.Value},
|
|
|
|
{"keeplogged", "1"}
|
2016-10-29 20:14:38 +00:00
|
|
|
};
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl, true);
|
2020-04-15 04:01:13 +00:00
|
|
|
await ConfigureIfOK(
|
|
|
|
result.Cookies, result.Content?.Contains("logout.php") == true, () =>
|
|
|
|
{
|
|
|
|
var errorMessage = result.Content;
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, ConfigData);
|
|
|
|
});
|
2016-10-29 20:14:38 +00:00
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
private static string InternationalTitle(string title)
|
2019-11-07 03:21:03 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
var match = Regex.Match(title, @".* \[(.*?)\]$");
|
|
|
|
return match.Success ? match.Groups[1].Value : title;
|
2019-11-07 03:21:03 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
|
|
|
|
private static 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
|
2020-04-15 04:01:13 +00:00
|
|
|
term = _EpisodeRegex.Replace(term, string.Empty);
|
|
|
|
term = isAnime ? Regex.Replace(term, @"\d*$", string.Empty) : term;
|
|
|
|
return term.TrimEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
private string ParseTitle(string title, string seasonEp, string year, string categoryStr)
|
|
|
|
{
|
|
|
|
var cleanTitle = _EpisodeRegex.Replace(title, string.Empty);
|
|
|
|
cleanTitle = Regex.Replace(cleanTitle, @"^\s*|[\s-]*$", string.Empty);
|
|
|
|
|
|
|
|
// Get international title if available, or use the full title if not
|
|
|
|
cleanTitle = InternationalTitle(cleanTitle);
|
|
|
|
foreach (var resultTerm in _commonResultTerms)
|
|
|
|
{
|
|
|
|
var newTitle = cleanTitle.ToLower().Replace(resultTerm.Key.ToLower(), resultTerm.Value);
|
|
|
|
if (!string.Equals(newTitle, cleanTitle, StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
cleanTitle = newTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// do not include year to animes
|
|
|
|
if (categoryStr == "14")
|
|
|
|
cleanTitle += " " + seasonEp;
|
|
|
|
else
|
|
|
|
cleanTitle += " " + year + " " + seasonEp;
|
|
|
|
return FixAbsoluteNumbering(cleanTitle);
|
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;
|
|
|
|
}
|
|
|
|
|
2020-05-03 22:21:54 +00:00
|
|
|
private string FixYearPosition(string title, string year)
|
|
|
|
{
|
|
|
|
int index = title.LastIndexOf('-');
|
|
|
|
// If its a series
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
title = title.Substring(0, index) + year + " " + title.Substring(index + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title += " " + year;
|
|
|
|
}
|
|
|
|
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
private string FixNovelNumber(string title)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (title.Contains("[Novela]"))
|
|
|
|
{
|
|
|
|
title = Regex.Replace(title, @"(Cap[\.]?[ ]?)", "S01E");
|
|
|
|
title = Regex.Replace(title, @"(\[Novela\]\ )", "");
|
|
|
|
title = Regex.Replace(title, @"(\ \-\s*Completo)", " - S01");
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
2019-12-27 20:04:43 +00:00
|
|
|
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))
|
2020-02-09 02:35:16 +00:00
|
|
|
{
|
2019-12-27 20:04:43 +00:00
|
|
|
title = Regex.Replace(title, @"(Ep[\.]?[ ]?)|([S]\d\d[Ee])", "");
|
|
|
|
return title;
|
2019-10-15 19:35:07 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
|
|
|
|
return title;
|
2016-11-01 08:22:52 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
private string FixSearchTerm(TorznabQuery query)
|
2016-10-29 20:14:38 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
if (query.IsImdbQuery)
|
|
|
|
return query.ImdbID;
|
|
|
|
return _commonSearchTerms.Aggregate(
|
|
|
|
query.GetQueryString(),
|
|
|
|
(current, searchTerm) => current.ToLower().Replace(searchTerm.Key.ToLower(), searchTerm.Value));
|
|
|
|
}
|
2020-02-09 02:35:16 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
// if the search string is empty use the "last 24h torrents" view
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) =>
|
|
|
|
(string.IsNullOrWhiteSpace(query.SearchTerm) && !query.IsImdbQuery)
|
|
|
|
? await ParseLast24HoursAsync()
|
|
|
|
: await ParseUserSearchAsync(query);
|
2017-10-29 06:21:18 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
private async Task<List<ReleaseInfo>> ParseUserSearchAsync(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
var searchUrl = BrowseUrl;
|
|
|
|
var isSearchAnime = query.Categories.Any(s => s == TorznabCatType.TVAnime.ID);
|
|
|
|
var searchTerm = FixSearchTerm(query);
|
|
|
|
var queryCollection = new NameValueCollection
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
{"searchstr", StripSearchString(searchTerm, isSearchAnime)},
|
|
|
|
{"order_by", "time"},
|
|
|
|
{"order_way", "desc"},
|
|
|
|
{"group_results", "1"},
|
|
|
|
{"action", "basic"},
|
|
|
|
{"searchsubmit", "1"}
|
|
|
|
};
|
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
queryCollection.Add("filter_cat[" + cat + "]", "1");
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
|
|
|
var results = await RequestStringWithCookies(searchUrl);
|
|
|
|
if (results.IsRedirect)
|
|
|
|
{
|
|
|
|
// re-login
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
results = await RequestStringWithCookies(searchUrl);
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
const string rowsSelector = "table.torrent_table > tbody > tr:not(tr.colhead)";
|
|
|
|
var searchResultParser = new HtmlParser();
|
|
|
|
var searchResultDocument = searchResultParser.ParseDocument(results.Content);
|
|
|
|
var rows = searchResultDocument.QuerySelectorAll(rowsSelector);
|
|
|
|
ICollection<int> groupCategory = null;
|
|
|
|
string groupTitle = null;
|
|
|
|
string groupYearStr = null;
|
|
|
|
var categoryStr = "";
|
|
|
|
foreach (var row in rows)
|
|
|
|
try
|
2016-10-29 20:14:38 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
// ignore sub groups info row, it's just an row with an info about the next section, something like "Dual Áudio" or "Legendado"
|
|
|
|
if (row.QuerySelector(".edition_info") != null)
|
|
|
|
continue;
|
|
|
|
var qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]");
|
|
|
|
var title = StripSearchString(qDetailsLink.TextContent, false);
|
|
|
|
var seasonEp = _EpisodeRegex.Match(qDetailsLink.TextContent).Value;
|
|
|
|
ICollection<int> category = null;
|
|
|
|
string yearStr = null;
|
|
|
|
if (row.ClassList.Contains("group") || row.ClassList.Contains("torrent")) // group/ungrouped headers
|
2016-10-29 20:14:38 +00:00
|
|
|
{
|
2018-05-20 19:07:00 +00:00
|
|
|
var qCatLink = row.QuerySelector("a[href^=\"/torrents.php?filter_cat\"]");
|
2020-04-15 04:01:13 +00:00
|
|
|
categoryStr = qCatLink.GetAttribute("href").Split('=')[1].Split('&')[0];
|
|
|
|
category = MapTrackerCatToNewznab(categoryStr);
|
|
|
|
yearStr = qDetailsLink.NextSibling.TextContent.Trim().TrimStart('[').TrimEnd(']');
|
|
|
|
if (row.ClassList.Contains("group")) // group headers
|
2017-11-20 14:27:25 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
groupCategory = category;
|
|
|
|
groupTitle = title;
|
|
|
|
groupYearStr = yearStr;
|
|
|
|
continue;
|
2017-11-20 14:27:25 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
}
|
2018-04-06 13:16:04 +00:00
|
|
|
|
2020-04-15 04:01:13 +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
|
|
|
|
{
|
|
|
|
release.Description = Regex.Match(qDetailsLink.TextContent, @"\[.*?\]").Value;
|
|
|
|
release.Title = ParseTitle(groupTitle, seasonEp, groupYearStr, categoryStr);
|
|
|
|
release.Category = groupCategory;
|
2016-10-29 20:14:38 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
else if (row.ClassList.Contains("torrent")) // standalone/un grouped torrents
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
release.Description = row.QuerySelector("div.torrent_info").TextContent;
|
|
|
|
release.Title = ParseTitle(title, seasonEp, yearStr, categoryStr);
|
|
|
|
release.Category = category;
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2018-05-20 19:07:00 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
release.Description = release.Description.Replace(" / Free", ""); // Remove Free Tag
|
2020-05-03 22:21:54 +00:00
|
|
|
release.Description = release.Description.Replace("/ WEB ", "/ WEB-DL "); // Fix web/web-dl
|
2020-04-15 04:01:13 +00:00
|
|
|
release.Description = release.Description.Replace("Full HD", "1080p");
|
|
|
|
// Handles HDR conflict
|
|
|
|
release.Description = release.Description.Replace("/ HD /", "/ 720p /");
|
|
|
|
release.Description = release.Description.Replace("/ HD]", "/ 720p]");
|
|
|
|
release.Description = release.Description.Replace("4K", "2160p");
|
|
|
|
release.Description = release.Description.Replace("SD", "480p");
|
|
|
|
release.Description = release.Description.Replace("Dual Áudio", "Dual");
|
|
|
|
|
|
|
|
// Adjust the description in order to can be read by Radarr and Sonarr
|
|
|
|
var cleanDescription = release.Description.Trim().TrimStart('[').TrimEnd(']');
|
|
|
|
string[] titleElements;
|
|
|
|
|
|
|
|
//Formats the title so it can be parsed later
|
|
|
|
var stringSeparators = new[]
|
|
|
|
{
|
|
|
|
" / "
|
|
|
|
};
|
|
|
|
titleElements = cleanDescription.Split(stringSeparators, StringSplitOptions.None);
|
|
|
|
// release.Title += string.Join(" ", titleElements);
|
|
|
|
release.Title = release.Title.Trim();
|
|
|
|
if (titleElements.Length < 6)
|
|
|
|
// Usually non movies / series could have less than 6 elements, eg: Books.
|
|
|
|
release.Title += " " + string.Join(" ", titleElements);
|
|
|
|
else
|
|
|
|
release.Title += " " + titleElements[5] + " " + titleElements[3] + " " + titleElements[1] + " " +
|
|
|
|
titleElements[2] + " " + titleElements[4] + " " + string.Join(
|
|
|
|
" ", titleElements.Skip(6));
|
|
|
|
|
|
|
|
// This tracker does not provide an publish date to search terms (only on last 24h page)
|
|
|
|
release.PublishDate = DateTime.Today;
|
|
|
|
|
|
|
|
// check for previously stripped search terms
|
|
|
|
if (!query.IsImdbQuery && !query.MatchQueryStringAND(release.Title, null, searchTerm))
|
|
|
|
continue;
|
|
|
|
var size = qSize.TextContent;
|
|
|
|
release.Size = ReleaseInfo.GetBytes(size);
|
|
|
|
release.Link = new Uri(SiteLink + qDlLink.GetAttribute("href"));
|
|
|
|
release.Comments = new Uri(SiteLink + qDetailsLink.GetAttribute("href"));
|
|
|
|
release.Guid = release.Link;
|
|
|
|
release.Grabs = ParseUtil.CoerceLong(qGrabs.TextContent);
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(qSeeders.TextContent);
|
|
|
|
release.Peers = ParseUtil.CoerceInt(qLeechers.TextContent) + release.Seeders;
|
|
|
|
release.DownloadVolumeFactor = qFreeLeech != null ? 0 : 1;
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
2018-12-01 11:37:41 +00:00
|
|
|
{
|
2020-05-11 19:59:28 +00:00
|
|
|
logger.Error($"{Id}: Error while parsing row '{row.OuterHtml}': {ex.Message}");
|
2018-12-01 11:37:41 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(results.Content, ex);
|
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
return releases;
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
private async Task<List<ReleaseInfo>> ParseLast24HoursAsync()
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
var results = await RequestStringWithCookies(TodayUrl);
|
|
|
|
if (results.IsRedirect)
|
|
|
|
{
|
|
|
|
// re-login
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
results = await RequestStringWithCookies(TodayUrl);
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
const string rowsSelector = "table.torrent_table > tbody > tr:not(tr.colhead)";
|
|
|
|
var searchResultParser = new HtmlParser();
|
|
|
|
var searchResultDocument = searchResultParser.ParseDocument(results.Content);
|
|
|
|
var rows = searchResultDocument.QuerySelectorAll(rowsSelector);
|
|
|
|
foreach (var row in rows)
|
|
|
|
try
|
2016-10-29 20:14:38 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
var release = new ReleaseInfo
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
MinimumRatio = 1,
|
|
|
|
MinimumSeedTime = 0
|
|
|
|
};
|
|
|
|
var qDetailsLink = row.QuerySelector("a.BJinfoBox");
|
|
|
|
var qBJinfoBox = qDetailsLink.QuerySelector("span");
|
|
|
|
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");
|
|
|
|
var year = "";
|
|
|
|
release.Description = "";
|
|
|
|
var extraInfo = "";
|
2020-05-03 22:21:54 +00:00
|
|
|
var releaseQuality = "";
|
2020-04-15 04:01:13 +00:00
|
|
|
foreach (var child in qBJinfoBox.ChildNodes)
|
|
|
|
{
|
|
|
|
var type = child.NodeType;
|
|
|
|
if (type != NodeType.Text)
|
|
|
|
continue;
|
|
|
|
var line = child.TextContent;
|
|
|
|
if (line.StartsWith("Tamanho:"))
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
var size = line.Substring("Tamanho: ".Length);
|
|
|
|
release.Size = ReleaseInfo.GetBytes(size);
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
else if (line.StartsWith("Lançado em: "))
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +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
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
else if (line.StartsWith("Ano:"))
|
2020-05-03 22:21:54 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
year = line.Substring("Ano: ".Length);
|
2020-05-03 22:21:54 +00:00
|
|
|
}
|
|
|
|
else if (line.StartsWith("Qualidade:"))
|
|
|
|
{
|
|
|
|
releaseQuality = line.Substring("Qualidade: ".Length);
|
|
|
|
if (releaseQuality == "WEB")
|
|
|
|
releaseQuality = "WEB-DL";
|
|
|
|
extraInfo += releaseQuality + " ";
|
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
else
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
release.Description += line + "\n";
|
|
|
|
if (line.Contains(":"))
|
|
|
|
if (!(line.StartsWith("Lançado") || line.StartsWith("Resolução") ||
|
|
|
|
line.StartsWith("Idioma") || line.StartsWith("Autor")))
|
2019-12-27 20:04:43 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
var info = line.Substring(line.IndexOf(": ", StringComparison.Ordinal) + 2);
|
|
|
|
if (info == "Dual Áudio")
|
|
|
|
info = "Dual";
|
|
|
|
extraInfo += info + " ";
|
2019-12-27 20:04:43 +00:00
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2016-10-29 20:14:38 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
|
|
|
|
var catStr = qCatLink.GetAttribute("href").Split('=')[1].Split('&')[0];
|
|
|
|
if (!string.IsNullOrEmpty(year))
|
2020-05-03 22:21:54 +00:00
|
|
|
release.Title = FixYearPosition(release.Title, year);
|
|
|
|
|
|
|
|
release.Title = FixAbsoluteNumbering(release.Title);
|
|
|
|
release.Title = FixNovelNumber(release.Title);
|
|
|
|
|
2020-04-15 04:01:13 +00:00
|
|
|
if (qQuality != null)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-15 04:01:13 +00:00
|
|
|
var quality = qQuality.TextContent;
|
|
|
|
release.Title += quality switch
|
|
|
|
{
|
|
|
|
"4K" => " 2160p",
|
|
|
|
"Full HD" => " 1080p",
|
|
|
|
"HD" => " 720p",
|
|
|
|
_ => " 480p"
|
|
|
|
};
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
|
|
|
|
release.Title += " " + extraInfo.TrimEnd();
|
|
|
|
release.Category = MapTrackerCatToNewznab(catStr);
|
|
|
|
release.Link = new Uri(SiteLink + qDlLink.GetAttribute("href"));
|
|
|
|
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;
|
|
|
|
release.DownloadVolumeFactor = qFreeLeech != null ? 0 : 1;
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
releases.Add(release);
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2020-04-15 04:01:13 +00:00
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-05-11 19:59:28 +00:00
|
|
|
logger.Error($"{Id}: Error while parsing row '{row.OuterHtml}': {ex.Message}");
|
2020-04-15 04:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(results.Content, ex);
|
2016-10-29 20:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|