2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2016-08-18 10:55:58 +00:00
|
|
|
using System.Collections.Generic;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2016-08-18 10:55:58 +00:00
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2016-08-18 10:55:58 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-02-29 23:06:58 +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:50:47 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2020-05-11 22:58:10 +00:00
|
|
|
public class PreToMe : BaseWebIndexer
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string LoginUrl => SiteLink + "takelogin.php";
|
|
|
|
private string SearchUrl => SiteLink + "browse.php";
|
2020-03-29 11:45:30 +00:00
|
|
|
private new ConfigurationDataPinNumber configData => (ConfigurationDataPinNumber)base.configData;
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2020-05-11 22:58:10 +00:00
|
|
|
public PreToMe(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "pretome",
|
|
|
|
name: "PreToMe",
|
|
|
|
description: "BitTorrent site for High Quality, High Definition (HD) movies and TV Shows",
|
|
|
|
link: "https://pretome.info/",
|
2020-10-13 20:17:26 +00:00
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
2020-10-18 20:47:36 +00:00
|
|
|
// TODO: add music and book search
|
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId
|
|
|
|
},
|
|
|
|
MovieSearchParams = new List<MovieSearchParam>
|
|
|
|
{
|
|
|
|
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
|
|
|
}
|
2020-10-13 20:17:26 +00:00
|
|
|
},
|
2020-05-11 19:59:28 +00:00
|
|
|
client: wc,
|
|
|
|
configService: configService,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
|
|
|
configData: new ConfigurationDataPinNumber("For best results, change the 'Torrents per page' setting to 100 in 'Profile => Torrent browse settings'."))
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2016-12-06 13:56:47 +00:00
|
|
|
Encoding = Encoding.GetEncoding("iso-8859-1");
|
2016-12-09 17:20:58 +00:00
|
|
|
Language = "en-us";
|
2017-01-27 15:57:32 +00:00
|
|
|
Type = "private";
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
// Unfortunately most of them are tags not categories and they return the parent category
|
|
|
|
// we have to re-add the tags with the parent category so the results are not removed with the filtering
|
|
|
|
|
|
|
|
// Applications
|
|
|
|
AddCategoryMappingAndParent("cat[]=22", TorznabCatType.PC);
|
|
|
|
AddCategoryMappingAndParent("cat[]=22&tags=Windows", TorznabCatType.PC0day, TorznabCatType.PC);
|
|
|
|
AddCategoryMappingAndParent("cat[]=22&tags=MAC", TorznabCatType.PCMac, TorznabCatType.PC);
|
|
|
|
AddCategoryMappingAndParent("cat[]=22&tags=Linux", TorznabCatType.PC, TorznabCatType.PC);
|
|
|
|
|
|
|
|
// Ebooks
|
|
|
|
AddCategoryMappingAndParent("cat[]=27", TorznabCatType.BooksEbook);
|
|
|
|
|
|
|
|
// Games
|
|
|
|
AddCategoryMappingAndParent("cat[]=4", TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=PC", TorznabCatType.PCGames, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=RIP", TorznabCatType.PCGames, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=ISO", TorznabCatType.PCGames, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=XBOX360", TorznabCatType.ConsoleXbox360, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=PS3", TorznabCatType.ConsolePS3, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=Wii", TorznabCatType.ConsoleWii, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=PSP", TorznabCatType.ConsolePSP, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=NSD", TorznabCatType.ConsoleNDS, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=XBox", TorznabCatType.ConsoleXbox, TorznabCatType.Console);
|
|
|
|
AddCategoryMappingAndParent("cat[]=4&tags=PS2", TorznabCatType.ConsoleOther, TorznabCatType.Console);
|
|
|
|
|
|
|
|
// Miscellaneous
|
|
|
|
AddCategoryMappingAndParent("cat[]=31", TorznabCatType.Other);
|
|
|
|
AddCategoryMappingAndParent("cat[]=31&tags=Ebook", TorznabCatType.BooksEbook, TorznabCatType.Other);
|
|
|
|
AddCategoryMappingAndParent("cat[]=31&tags=RARFiX", TorznabCatType.Other, TorznabCatType.Other);
|
|
|
|
|
|
|
|
// Movies
|
|
|
|
AddCategoryMappingAndParent("cat[]=19", TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=x264", TorznabCatType.Movies, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=720p", TorznabCatType.MoviesHD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=XviD", TorznabCatType.MoviesSD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=BluRay", TorznabCatType.MoviesHD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=DVDRiP", TorznabCatType.MoviesSD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=1080p", TorznabCatType.MoviesHD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=DVD", TorznabCatType.MoviesSD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=DVDR", TorznabCatType.MoviesSD, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=WMV", TorznabCatType.Movies, TorznabCatType.Movies);
|
|
|
|
AddCategoryMappingAndParent("cat[]=19&tags=CAM", TorznabCatType.Movies, TorznabCatType.Movies);
|
|
|
|
|
|
|
|
// Music
|
|
|
|
AddCategoryMappingAndParent("cat[]=6", TorznabCatType.Audio);
|
|
|
|
AddCategoryMappingAndParent("cat[]=6&tags=MP3", TorznabCatType.AudioMP3, TorznabCatType.Audio);
|
|
|
|
AddCategoryMappingAndParent("cat[]=6&tags=V2", TorznabCatType.AudioMP3, TorznabCatType.Audio);
|
|
|
|
AddCategoryMappingAndParent("cat[]=6&tags=FLAC", TorznabCatType.AudioLossless, TorznabCatType.Audio);
|
|
|
|
AddCategoryMappingAndParent("cat[]=6&tags=320kbps", TorznabCatType.AudioMP3, TorznabCatType.Audio);
|
|
|
|
|
|
|
|
// TV
|
|
|
|
AddCategoryMappingAndParent("cat[]=7", TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=x264", TorznabCatType.TVHD, TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=720p", TorznabCatType.TVHD, TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=HDTV", TorznabCatType.TVHD, TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=XviD", TorznabCatType.TVSD, TorznabCatType.TV);
|
2020-04-30 10:34:03 +00:00
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=BluRay", TorznabCatType.TVHD, TorznabCatType.TV);
|
2020-10-09 22:32:53 +00:00
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=DVDRiP", TorznabCatType.TVSD, TorznabCatType.TV);
|
2020-03-29 11:45:30 +00:00
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=DVD", TorznabCatType.TVSD, TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=Documentary", TorznabCatType.TVDocumentary, TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=PDTV", TorznabCatType.TVSD, TorznabCatType.TV);
|
|
|
|
AddCategoryMappingAndParent("cat[]=7&tags=HD-DVD", TorznabCatType.TVSD, TorznabCatType.TV);
|
|
|
|
|
|
|
|
// XXX
|
|
|
|
AddCategoryMappingAndParent("cat[]=51", TorznabCatType.XXX);
|
|
|
|
AddCategoryMappingAndParent("cat[]=51&tags=XviD", TorznabCatType.XXXXviD, TorznabCatType.XXX);
|
|
|
|
AddCategoryMappingAndParent("cat[]=51&tags=DVDRiP", TorznabCatType.XXXDVD, TorznabCatType.XXX);
|
2016-08-18 10:55:58 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
private void AddCategoryMappingAndParent(string trackerCategory, TorznabCategory newznabCategory,
|
|
|
|
TorznabCategory parentCategory = null)
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2020-03-29 11:45:30 +00:00
|
|
|
AddCategoryMapping(trackerCategory, newznabCategory);
|
|
|
|
if (parentCategory != null && parentCategory.ID != newznabCategory.ID)
|
|
|
|
AddCategoryMapping(trackerCategory, parentCategory);
|
2016-08-18 10:55:58 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2017-01-02 20:39:28 +00:00
|
|
|
LoadValuesFromJson(configJson);
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2020-09-21 16:39:47 +00:00
|
|
|
var loginPage = await RequestWithCookiesAsync(LoginUrl, string.Empty);
|
2016-08-18 10:55:58 +00:00
|
|
|
|
|
|
|
var pairs = new Dictionary<string, string> {
|
|
|
|
{ "returnto", "%2F" },
|
|
|
|
{ "login_pin", configData.Pin.Value },
|
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
{ "password", configData.Password.Value },
|
|
|
|
{ "login", "Login" }
|
|
|
|
};
|
|
|
|
|
|
|
|
// Send Post
|
2020-09-21 16:39:47 +00:00
|
|
|
var result = await RequestWithCookiesAsync(LoginUrl, loginPage.Cookies, RequestType.POST, data: pairs);
|
2016-08-18 10:55:58 +00:00
|
|
|
if (result.RedirectingTo == null)
|
|
|
|
throw new ExceptionWithConfigData("Login failed. Did you use the PIN number that pretome emailed you?", configData);
|
2020-03-29 11:45:30 +00:00
|
|
|
|
2016-08-18 10:55:58 +00:00
|
|
|
// Get result from redirect
|
2020-03-29 11:45:30 +00:00
|
|
|
var loginCookies = result.Cookies;
|
2016-08-18 10:55:58 +00:00
|
|
|
await FollowIfRedirect(result, LoginUrl, null, loginCookies);
|
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
await ConfigureIfOK(loginCookies, result.ContentString?.Contains("logout.php") == true,
|
2020-03-30 01:25:21 +00:00
|
|
|
() => throw new ExceptionWithConfigData("Login failed", configData));
|
2016-08-18 10:55:58 +00:00
|
|
|
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
2020-03-30 01:25:21 +00:00
|
|
|
var qc = new List<KeyValuePair<string, string>> // NameValueCollection don't support cat[]=19&cat[]=6
|
|
|
|
{
|
|
|
|
{"st", "1"} // search in title
|
|
|
|
};
|
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
if (query.IsImdbQuery)
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2020-03-29 11:45:30 +00:00
|
|
|
qc.Add("search", query.ImdbID);
|
2020-03-30 01:25:21 +00:00
|
|
|
qc.Add("sd", "1"); // search in description
|
2016-08-18 10:55:58 +00:00
|
|
|
}
|
2020-03-30 01:25:21 +00:00
|
|
|
else
|
2020-03-29 11:45:30 +00:00
|
|
|
qc.Add("search", query.GetQueryString());
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
// parse categories and tags
|
|
|
|
var catGroups = new HashSet<string>(); // HashSet instead of List to avoid duplicates
|
|
|
|
var tagGroups = new HashSet<string>();
|
|
|
|
var cats = MapTorznabCapsToTrackers(query);
|
|
|
|
foreach (var cat in cats)
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2020-03-29 11:45:30 +00:00
|
|
|
// "cat[]=7&tags=x264"
|
|
|
|
var cSplit = cat.Split('&');
|
|
|
|
|
|
|
|
var gSplit = cSplit[0].Split('=');
|
|
|
|
if (gSplit.Length > 1)
|
|
|
|
catGroups.Add(gSplit[1]); // category = 7
|
|
|
|
|
|
|
|
if (cSplit.Length > 1)
|
2017-10-29 06:50:47 +00:00
|
|
|
{
|
2020-03-29 11:45:30 +00:00
|
|
|
var tSplit = cSplit[1].Split('=');
|
|
|
|
if (tSplit.Length > 1)
|
|
|
|
tagGroups.Add(tSplit[1]); // tag = x264
|
2016-10-25 06:46:06 +00:00
|
|
|
}
|
2016-08-18 10:55:58 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
// add categories
|
|
|
|
foreach (var cat in catGroups)
|
|
|
|
qc.Add("cat[]", cat);
|
|
|
|
|
|
|
|
// do not include too many tags as it'll mess with their servers
|
|
|
|
if (tagGroups.Count < 7)
|
2016-08-18 10:55:58 +00:00
|
|
|
{
|
2020-03-29 11:45:30 +00:00
|
|
|
qc.Add("tags", string.Join(",", tagGroups));
|
|
|
|
// if tags are specified match any
|
|
|
|
// if no tags are specified match all, with any we get random results
|
|
|
|
qc.Add("tf", tagGroups.Any() ? "any" : "all");
|
2016-08-18 10:55:58 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
var searchUrl = SearchUrl + "?" + qc.GetQueryString();
|
2020-06-11 15:09:27 +00:00
|
|
|
var response = await RequestWithCookiesAndRetryAsync(searchUrl);
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2020-03-29 11:45:30 +00:00
|
|
|
if (response.IsRedirect) // re-login
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
|
|
|
await ApplyConfiguration(null);
|
2020-06-11 15:09:27 +00:00
|
|
|
response = await RequestWithCookiesAndRetryAsync(searchUrl);
|
2016-12-10 21:32:41 +00:00
|
|
|
}
|
|
|
|
|
2016-08-18 10:55:58 +00:00
|
|
|
try
|
|
|
|
{
|
2020-02-29 23:06:58 +00:00
|
|
|
var parser = new HtmlParser();
|
2020-06-09 17:36:57 +00:00
|
|
|
var dom = parser.ParseDocument(response.ContentString);
|
2020-02-29 23:06:58 +00:00
|
|
|
var rows = dom.QuerySelectorAll("table > tbody > tr.browse");
|
2016-08-18 10:55:58 +00:00
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
2020-02-29 23:06:58 +00:00
|
|
|
var qLink = row.Children[1].QuerySelector("a");
|
2020-03-26 22:15:28 +00:00
|
|
|
var title = qLink.GetAttribute("title");
|
|
|
|
if (qLink.QuerySelectorAll("span").Length == 1 && title.StartsWith("NEW! |"))
|
|
|
|
title = title.Substring(6).Trim();
|
2020-03-29 11:45:30 +00:00
|
|
|
|
|
|
|
if (!query.MatchQueryStringAND(title))
|
|
|
|
continue; // we have to skip bad titles due to tags + any word search
|
2016-08-18 10:55:58 +00:00
|
|
|
|
2020-03-26 22:15:28 +00:00
|
|
|
var comments = new Uri(SiteLink + qLink.GetAttribute("href"));
|
2020-03-29 11:45:30 +00:00
|
|
|
var link = new Uri(SiteLink + row.Children[2].QuerySelector("a").GetAttribute("href"));
|
2020-02-29 23:06:58 +00:00
|
|
|
var dateStr = Regex.Replace(row.Children[5].InnerHtml, @"\<br[\s]{0,1}[\/]{0,1}\>", " ");
|
2020-03-26 22:15:28 +00:00
|
|
|
var publishDate = DateTimeUtil.FromTimeAgo(dateStr);
|
2020-03-29 11:45:30 +00:00
|
|
|
var files = ParseUtil.CoerceInt(row.Children[3].TextContent);
|
|
|
|
var size = ReleaseInfo.GetBytes(row.Children[7].TextContent);
|
|
|
|
var grabs = ParseUtil.CoerceInt(row.Children[8].TextContent);
|
|
|
|
var seeders = ParseUtil.CoerceInt(row.Children[9].TextContent);
|
2020-03-26 22:15:28 +00:00
|
|
|
var leechers = ParseUtil.CoerceInt(row.Children[10].TextContent);
|
2020-03-29 11:45:30 +00:00
|
|
|
var cat = row.FirstElementChild.FirstElementChild.GetAttribute("href").Replace("browse.php?", string.Empty);
|
|
|
|
|
2020-03-26 22:15:28 +00:00
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
Title = title,
|
|
|
|
Comments = comments,
|
|
|
|
Guid = comments,
|
|
|
|
Link = link,
|
|
|
|
PublishDate = publishDate,
|
|
|
|
Size = size,
|
|
|
|
Category = MapTrackerCatToNewznab(cat),
|
|
|
|
Files = files,
|
|
|
|
Grabs = grabs,
|
2020-03-29 11:45:30 +00:00
|
|
|
Seeders = seeders,
|
|
|
|
Peers = leechers + seeders,
|
2020-10-09 22:32:53 +00:00
|
|
|
MinimumRatio = 0.75,
|
|
|
|
MinimumSeedTime = 216000, // 60 hours
|
2020-03-26 22:15:28 +00:00
|
|
|
DownloadVolumeFactor = 0, // ratioless
|
|
|
|
UploadVolumeFactor = 1
|
|
|
|
};
|
2020-03-29 11:45:30 +00:00
|
|
|
|
2016-08-18 10:55:58 +00:00
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-06-09 17:36:57 +00:00
|
|
|
OnParseError(response.ContentString, ex);
|
2016-08-18 10:55:58 +00:00
|
|
|
}
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|