2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2017-09-11 13:10:54 +00:00
|
|
|
using System.Collections.Generic;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-03-29 11:46:10 +00:00
|
|
|
using System.Linq;
|
2017-09-11 13:10:54 +00:00
|
|
|
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
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2017-09-11 13:10:54 +00:00
|
|
|
public class PolishTracker : BaseWebIndexer
|
|
|
|
{
|
2020-03-29 11:46:10 +00:00
|
|
|
private string SearchUrl => SiteLink + "apitorrents";
|
|
|
|
private static string CdnUrl => "https://cdn.pte.nu/";
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-03-29 11:46:10 +00:00
|
|
|
public override string[] LegacySiteLinks { get; protected set; } = {
|
2020-10-19 21:19:10 +00:00
|
|
|
"https://polishtracker.net/"
|
2020-03-29 11:46:10 +00:00
|
|
|
};
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-10-01 19:06:38 +00:00
|
|
|
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)base.configData;
|
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)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "polishtracker",
|
|
|
|
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/",
|
2020-04-03 22:37:42 +00:00
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
2020-10-18 20:47:36 +00:00
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId
|
|
|
|
},
|
|
|
|
MovieSearchParams = new List<MovieSearchParam>
|
|
|
|
{
|
|
|
|
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
2020-10-20 00:38:27 +00:00
|
|
|
},
|
|
|
|
MusicSearchParams = new List<MusicSearchParam>
|
|
|
|
{
|
|
|
|
MusicSearchParam.Q
|
|
|
|
},
|
|
|
|
BookSearchParams = new List<BookSearchParam>
|
|
|
|
{
|
|
|
|
BookSearchParam.Q
|
2020-10-18 20:47:36 +00:00
|
|
|
}
|
2020-04-03 22:37:42 +00:00
|
|
|
},
|
2017-09-11 13:10:54 +00:00
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-10-01 19:06:38 +00:00
|
|
|
configData: new ConfigurationDataCookie())
|
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);
|
|
|
|
|
2020-10-01 19:06:38 +00:00
|
|
|
CookieHeader = configData.Cookie.Value;
|
|
|
|
try
|
2017-09-11 13:10:54 +00:00
|
|
|
{
|
2020-10-01 19:06:38 +00:00
|
|
|
var results = await PerformQuery(new TorznabQuery());
|
|
|
|
if (!results.Any())
|
|
|
|
throw new Exception("Found 0 results in the tracker");
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-10-01 19:06:38 +00:00
|
|
|
IsConfigured = true;
|
|
|
|
SaveConfig();
|
|
|
|
return IndexerConfigurationStatus.Completed;
|
|
|
|
}
|
|
|
|
catch (Exception)
|
2017-09-11 13:10:54 +00:00
|
|
|
{
|
2020-10-01 19:06:38 +00:00
|
|
|
IsConfigured = false;
|
|
|
|
throw;
|
|
|
|
}
|
2017-09-11 13:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
2020-03-29 11:46:10 +00:00
|
|
|
var qc = new List<KeyValuePair<string, string>> // NameValueCollection don't support cat[]=19&cat[]=6
|
2020-03-26 22:15:28 +00:00
|
|
|
{
|
|
|
|
{ "tpage", "1" }
|
|
|
|
};
|
2020-03-29 11:46:10 +00:00
|
|
|
|
|
|
|
if (query.IsImdbQuery)
|
2017-09-11 13:10:54 +00:00
|
|
|
{
|
2020-03-29 11:46:10 +00:00
|
|
|
qc.Add("search", query.ImdbID);
|
|
|
|
qc.Add("nfo", "true");
|
2017-09-11 13:10:54 +00:00
|
|
|
}
|
2020-03-29 11:46:10 +00:00
|
|
|
else if (!string.IsNullOrWhiteSpace(query.GetQueryString()))
|
|
|
|
qc.Add("search", query.GetQueryString());
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-03-29 11:46:10 +00:00
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
qc.Add("cat[]", cat);
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-03-29 11:46:10 +00:00
|
|
|
var searchUrl = SearchUrl + "?" + qc.GetQueryString();
|
2020-06-11 15:09:27 +00:00
|
|
|
var result = await RequestWithCookiesAndRetryAsync(searchUrl, referer: SearchUrl);
|
2017-09-11 13:10:54 +00:00
|
|
|
if (result.IsRedirect)
|
2020-10-01 19:06:38 +00:00
|
|
|
throw new Exception($"Your cookie did not work. Please, configure the tracker again. Message: {result.ContentString}");
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
if (!result.ContentString.StartsWith("{")) // not JSON => error
|
|
|
|
throw new ExceptionWithConfigData(result.ContentString, configData);
|
2020-03-29 11:46:10 +00:00
|
|
|
|
2020-06-09 17:36:57 +00:00
|
|
|
var json = JsonConvert.DeserializeObject<dynamic>(result.ContentString);
|
2017-09-11 13:10:54 +00:00
|
|
|
try
|
|
|
|
{
|
2020-03-29 11:46:10 +00:00
|
|
|
var torrents = json["torrents"]; // latest torrents
|
2017-09-11 13:10:54 +00:00
|
|
|
if (json["hits"] != null) // is search result
|
|
|
|
torrents = json.SelectTokens("$.hits[?(@._type == 'torrent')]._source");
|
|
|
|
foreach (var torrent in torrents)
|
|
|
|
{
|
2020-03-29 11:46:10 +00:00
|
|
|
var torrentId = (long)torrent.id;
|
|
|
|
var comments = new Uri(SiteLink + "torrents/" + torrentId);
|
|
|
|
var link = new Uri(SiteLink + "download/" + torrentId);
|
|
|
|
var publishDate = DateTime.Parse(torrent.added.ToString());
|
|
|
|
var imdbId = ParseUtil.GetImdbID(torrent.imdb_id.ToString());
|
|
|
|
|
2020-11-07 23:43:33 +00:00
|
|
|
Uri poster = null;
|
2020-03-29 11:46:10 +00:00
|
|
|
if ((bool)torrent.poster)
|
2017-10-29 06:50:47 +00:00
|
|
|
{
|
2020-03-29 11:46:10 +00:00
|
|
|
if (torrent["imdb_id"] != null)
|
2020-11-07 23:43:33 +00:00
|
|
|
poster = new Uri(CdnUrl + "images/torrents/poster/imd/l/" + torrent["imdb_id"] + ".jpg");
|
2017-09-11 13:10:54 +00:00
|
|
|
else if (torrent["cdu_id"] != null)
|
2020-11-07 23:43:33 +00:00
|
|
|
poster = new Uri(CdnUrl + "images/torrents/poster/cdu/b/" + torrent["cdu_id"] + "_front.jpg");
|
2017-09-11 13:10:54 +00:00
|
|
|
else if (torrent["steam_id"] != null)
|
2020-11-07 23:43:33 +00:00
|
|
|
poster = new Uri(CdnUrl + "images/torrents/poster/ste/l/" + torrent["steam_id"] + ".jpg");
|
2017-09-11 13:10:54 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 11:46:10 +00:00
|
|
|
var descriptions = new List<string>();
|
2017-09-11 13:10:54 +00:00
|
|
|
var language = (string)torrent.language;
|
|
|
|
if (!string.IsNullOrEmpty(language))
|
|
|
|
descriptions.Add("Language: " + language);
|
|
|
|
else if ((bool?)torrent.polish == true)
|
|
|
|
descriptions.Add("Language: pl");
|
2020-03-29 11:46:10 +00:00
|
|
|
var description = descriptions.Any() ? string.Join("<br />\n", descriptions) : null;
|
2017-09-11 13:10:54 +00:00
|
|
|
|
2020-03-29 11:46:10 +00:00
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
Title = torrent.name.ToString(),
|
|
|
|
Comments = comments,
|
|
|
|
Guid = comments,
|
|
|
|
Link = link,
|
|
|
|
PublishDate = publishDate,
|
|
|
|
Category = MapTrackerCatToNewznab(torrent.category.ToString()),
|
|
|
|
Size = (long)torrent.size,
|
|
|
|
Grabs = (long)torrent.completed,
|
|
|
|
Seeders = (int)torrent.seeders,
|
|
|
|
Peers = (int)torrent.seeders + (int)torrent.leechers,
|
|
|
|
Imdb = imdbId,
|
2020-11-07 23:43:33 +00:00
|
|
|
Poster = poster,
|
2020-03-29 11:46:10 +00:00
|
|
|
Description = description,
|
|
|
|
MinimumRatio = 1,
|
|
|
|
MinimumSeedTime = 259200, // 72 hours (I can't verify this, but this is a safe value in most trackers)
|
|
|
|
UploadVolumeFactor = 1,
|
|
|
|
DownloadVolumeFactor = 1
|
|
|
|
};
|
2017-09-11 13:10:54 +00:00
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(result.ToString(), ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|