2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2017-09-11 13:10:54 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Threading.Tasks;
|
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-09-11 13:10:54 +00:00
|
|
|
using Newtonsoft.Json;
|
2017-10-29 06:50:47 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2017-09-11 13:10:54 +00:00
|
|
|
{
|
|
|
|
public class PolishTracker : BaseWebIndexer
|
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
private string LoginUrl => SiteLink + "login";
|
|
|
|
private string TorrentApiUrl => SiteLink + "apitorrents";
|
|
|
|
private string CDNUrl => "https://cdn.pte.nu/";
|
2017-09-11 13:10:54 +00:00
|
|
|
|
|
|
|
public override string[] LegacySiteLinks { get; protected set; } = new string[] {
|
|
|
|
"https://polishtracker.net/",
|
|
|
|
};
|
|
|
|
|
2019-02-27 18:41:53 +00:00
|
|
|
private new ConfigurationDataBasicLoginWithEmail configData
|
2017-09-11 13:10:54 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
get => (ConfigurationDataBasicLoginWithEmail)base.configData;
|
|
|
|
set => base.configData = value;
|
2017-09-11 13:10:54 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
public PolishTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2017-09-11 13:10:54 +00:00
|
|
|
: base(name: "PolishTracker",
|
2017-10-04 05:05:10 +00:00
|
|
|
description: "Polish Tracker is a POLISH Private site for 0DAY / MOVIES / GENERAL",
|
2017-09-11 13:10:54 +00:00
|
|
|
link: "https://pte.nu/",
|
|
|
|
caps: new TorznabCapabilities(),
|
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2019-02-27 18:41:53 +00:00
|
|
|
configData: new ConfigurationDataBasicLoginWithEmail())
|
2017-09-11 13:10:54 +00:00
|
|
|
{
|
2020-02-09 02:35:16 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
2017-09-11 13:10:54 +00:00
|
|
|
Language = "pl-pl";
|
|
|
|
Type = "private";
|
|
|
|
|
|
|
|
AddCategoryMapping(1, TorznabCatType.PC0day, "0-Day");
|
|
|
|
AddCategoryMapping(3, TorznabCatType.PC0day, "Apps");
|
|
|
|
AddCategoryMapping(4, TorznabCatType.Console, "Consoles");
|
|
|
|
AddCategoryMapping(5, TorznabCatType.Books, "E-book");
|
|
|
|
AddCategoryMapping(6, TorznabCatType.MoviesHD, "Movies HD");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.MoviesSD, "Movies SD");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.Audio, "Music");
|
2018-01-10 13:37:01 +00:00
|
|
|
AddCategoryMapping(9, TorznabCatType.MoviesUHD, "Movies UHD");
|
2017-09-11 13:10:54 +00:00
|
|
|
AddCategoryMapping(10, TorznabCatType.PCGames, "PcGames");
|
|
|
|
AddCategoryMapping(11, TorznabCatType.TVHD, "TV HD");
|
|
|
|
AddCategoryMapping(12, TorznabCatType.TVSD, "TV SD");
|
|
|
|
AddCategoryMapping(13, TorznabCatType.XXX, "XXX");
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
|
|
|
{
|
|
|
|
LoadValuesFromJson(configJson);
|
|
|
|
|
|
|
|
var pairs = new Dictionary<string, string>
|
|
|
|
{
|
2019-02-27 18:41:53 +00:00
|
|
|
{ "email", configData.Email.Value },
|
2017-09-11 13:10:54 +00:00
|
|
|
{ "pass", configData.Password.Value }
|
|
|
|
};
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, SiteLink);
|
|
|
|
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Cookies != null && result.Cookies.Contains("id="), () =>
|
|
|
|
{
|
|
|
|
var errorMessage = result.Content;
|
2019-02-27 18:41:53 +00:00
|
|
|
if (errorMessage.Contains("Error!"))
|
|
|
|
errorMessage = "E-mail or password is incorrect";
|
2017-09-11 13:10:54 +00:00
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
});
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
|
|
|
var searchUrl = TorrentApiUrl;
|
|
|
|
var searchString = query.GetQueryString();
|
2018-01-10 13:37:01 +00:00
|
|
|
var queryCollection = new List<KeyValuePair<string, string>>();
|
|
|
|
|
2017-09-11 13:10:54 +00:00
|
|
|
queryCollection.Add("tpage", "1");
|
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
{
|
|
|
|
queryCollection.Add("cat[]", cat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchString))
|
|
|
|
queryCollection.Add("search", searchString);
|
|
|
|
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
|
|
|
|
|
|
|
var result = await RequestStringWithCookiesAndRetry(searchUrl, null, TorrentApiUrl);
|
|
|
|
if (result.IsRedirect)
|
|
|
|
{
|
|
|
|
// re-login
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
result = await RequestStringWithCookiesAndRetry(searchUrl, null, TorrentApiUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!result.Content.StartsWith("{")) // not JSON => error
|
|
|
|
throw new ExceptionWithConfigData(result.Content, configData);
|
|
|
|
dynamic json = JsonConvert.DeserializeObject<dynamic>(result.Content);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
dynamic torrents = json["torrents"]; // latest torrents
|
|
|
|
|
|
|
|
if (json["hits"] != null) // is search result
|
|
|
|
torrents = json.SelectTokens("$.hits[?(@._type == 'torrent')]._source");
|
|
|
|
/*
|
2017-10-29 06:50:47 +00:00
|
|
|
{
|
2017-09-11 13:10:54 +00:00
|
|
|
"id":426868,
|
|
|
|
"name":"Realease-nameE",
|
|
|
|
"size":"2885494332",
|
|
|
|
"category":11,
|
|
|
|
"added":"2017-09-11T11:36:26.936Z",
|
|
|
|
"comments":0,
|
|
|
|
"leechers":0,
|
|
|
|
"seeders":1,
|
|
|
|
"completed":0,
|
|
|
|
"poster":true,
|
|
|
|
"imdb_id":"3743822",
|
|
|
|
"cdu_id":null,
|
|
|
|
"steam_id":null,
|
|
|
|
"subs":null,
|
|
|
|
"language":"en"
|
|
|
|
},
|
|
|
|
*/
|
|
|
|
|
|
|
|
foreach (var torrent in torrents)
|
|
|
|
{
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
var descriptions = new List<string>();
|
|
|
|
release.MinimumRatio = 1;
|
|
|
|
release.MinimumSeedTime = 0;
|
|
|
|
|
|
|
|
release.Category = MapTrackerCatToNewznab(torrent.category.ToString());
|
|
|
|
release.Title = torrent.name.ToString();
|
|
|
|
var torrentID = (long)torrent.id;
|
|
|
|
release.Comments = new Uri(SiteLink + "torrents/" + torrentID);
|
|
|
|
release.Guid = release.Comments;
|
|
|
|
release.Link = new Uri(SiteLink + "download/" + torrentID);
|
|
|
|
var date = (DateTime)torrent.added;
|
|
|
|
release.PublishDate = date;
|
|
|
|
release.Size = ParseUtil.CoerceLong(torrent.size.ToString());
|
|
|
|
release.Seeders = (int)torrent.seeders;
|
|
|
|
release.Peers = release.Seeders + (int)torrent.leechers;
|
|
|
|
var imdbid = torrent.imdb_id.ToString();
|
|
|
|
if (!string.IsNullOrEmpty(imdbid))
|
|
|
|
release.Imdb = ParseUtil.CoerceLong(imdbid);
|
|
|
|
|
|
|
|
if ((bool)torrent.poster == true)
|
2017-10-29 06:50:47 +00:00
|
|
|
{
|
2017-09-11 13:10:54 +00:00
|
|
|
if (release.Imdb != null)
|
|
|
|
release.BannerUrl = new Uri(CDNUrl + "images/torrents/poster/imd/l/" + imdbid + ".jpg");
|
|
|
|
else if (torrent["cdu_id"] != null)
|
|
|
|
release.BannerUrl = new Uri(CDNUrl + "images/torrents/poster/cdu/b/" + torrent["cdu_id"] + "_front.jpg");
|
|
|
|
else if (torrent["steam_id"] != null)
|
|
|
|
release.BannerUrl = new Uri(CDNUrl + "images/torrents/poster/ste/l/" + torrent["steam_id"] + ".jpg");
|
|
|
|
}
|
|
|
|
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
|
|
|
release.Grabs = (long)torrent.completed;
|
|
|
|
|
|
|
|
var language = (string)torrent.language;
|
|
|
|
if (!string.IsNullOrEmpty(language))
|
|
|
|
descriptions.Add("Language: " + language);
|
|
|
|
else if ((bool?)torrent.polish == true)
|
|
|
|
descriptions.Add("Language: pl");
|
|
|
|
|
|
|
|
if (descriptions.Count > 0)
|
2017-10-29 06:50:47 +00:00
|
|
|
release.Description = string.Join("<br />\n", descriptions);
|
2017-09-11 13:10:54 +00:00
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(result.ToString(), ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|