2017-11-13 08:42:25 +00:00
|
|
|
using System;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Specialized;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Linq;
|
2020-10-04 18:29:00 +00:00
|
|
|
using System.Net;
|
2017-10-29 06:50:47 +00:00
|
|
|
using System.Text;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
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;
|
2017-04-15 08:45:10 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
2020-10-04 18:29:00 +00:00
|
|
|
using WebClient = Jackett.Common.Utils.Clients.WebClient;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2017-07-10 20:58:44 +00:00
|
|
|
public class TorrentSyndikat : BaseWebIndexer
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-10-04 18:29:00 +00:00
|
|
|
private string ApiBase => SiteLink + "api_9djWe8Tb2NE3p6opyqnh/v1";
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
private ConfigurationDataAPIKey ConfigData
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-10-19 20:50:19 +00:00
|
|
|
get => (ConfigurationDataAPIKey)configData;
|
|
|
|
set => configData = value;
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
public TorrentSyndikat(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "torrentsyndikat",
|
|
|
|
name: "Torrent-Syndikat",
|
|
|
|
description: "A German general tracker",
|
|
|
|
link: "https://torrent-syndikat.org/",
|
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
2020-10-18 20:47:36 +00:00
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
|
|
|
|
},
|
|
|
|
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-05-11 19:59:28 +00:00
|
|
|
},
|
|
|
|
configService: configService,
|
|
|
|
client: w,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-10-04 18:29:00 +00:00
|
|
|
configData: new ConfigurationDataAPIKey())
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2017-11-05 09:42:03 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
2017-04-15 08:45:10 +00:00
|
|
|
Language = "de-de";
|
|
|
|
Type = "private";
|
|
|
|
|
2018-03-25 15:14:27 +00:00
|
|
|
AddCategoryMapping(2, TorznabCatType.PC, "Apps / Windows");
|
|
|
|
AddCategoryMapping(13, TorznabCatType.PC, "Apps / Linux");
|
2018-09-05 16:00:05 +00:00
|
|
|
AddCategoryMapping(4, TorznabCatType.PCMac, "Apps / MacOS");
|
2018-03-25 15:14:27 +00:00
|
|
|
AddCategoryMapping(6, TorznabCatType.PC, "Apps / Misc");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-09-05 16:00:05 +00:00
|
|
|
AddCategoryMapping(50, TorznabCatType.PCGames, "Spiele / Windows");
|
|
|
|
AddCategoryMapping(51, TorznabCatType.PCGames, "Spiele / MacOS");
|
|
|
|
AddCategoryMapping(52, TorznabCatType.PCGames, "Spiele / Linux");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.ConsoleOther, "Spiele / Playstation");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.ConsoleOther, "Spiele / Nintendo");
|
|
|
|
AddCategoryMapping(32, TorznabCatType.ConsoleOther, "Spiele / XBOX");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-03-25 15:14:27 +00:00
|
|
|
AddCategoryMapping(42, TorznabCatType.MoviesUHD, "Filme / 2160p");
|
|
|
|
AddCategoryMapping(9, TorznabCatType.MoviesHD, "Filme / 1080p");
|
|
|
|
AddCategoryMapping(20, TorznabCatType.MoviesHD, "Filme / 720p");
|
|
|
|
AddCategoryMapping(10, TorznabCatType.MoviesSD, "Filme / SD");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-09-05 16:00:05 +00:00
|
|
|
AddCategoryMapping(43, TorznabCatType.TVUHD, "Serien / 2160p");
|
|
|
|
AddCategoryMapping(53, TorznabCatType.TVHD, "Serien / 1080p");
|
|
|
|
AddCategoryMapping(54, TorznabCatType.TVHD, "Serien / 720p");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.TVSD, "Serien / SD");
|
|
|
|
AddCategoryMapping(30, TorznabCatType.TVSport, "Serien / Sport");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-09-05 16:00:05 +00:00
|
|
|
AddCategoryMapping(44, TorznabCatType.TVUHD, "Serienpacks / 2160p");
|
|
|
|
AddCategoryMapping(55, TorznabCatType.TVHD, "Serienpacks / 1080p");
|
|
|
|
AddCategoryMapping(56, TorznabCatType.TVHD, "Serienpacks / 720p");
|
|
|
|
AddCategoryMapping(27, TorznabCatType.TVSD, "Serienpacks / SD");
|
|
|
|
|
|
|
|
AddCategoryMapping(24, TorznabCatType.AudioLossless, "Audio / Musik / FLAC");
|
|
|
|
AddCategoryMapping(25, TorznabCatType.AudioMP3, "Audio / Musik / MP3");
|
2018-03-25 15:14:27 +00:00
|
|
|
AddCategoryMapping(35, TorznabCatType.AudioOther, "Audio / Other");
|
|
|
|
AddCategoryMapping(18, TorznabCatType.AudioAudiobook, "Audio / aBooks");
|
|
|
|
AddCategoryMapping(33, TorznabCatType.AudioVideo, "Audio / Videos");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-03-25 15:14:27 +00:00
|
|
|
AddCategoryMapping(17, TorznabCatType.Books, "Misc / eBooks");
|
|
|
|
AddCategoryMapping(5, TorznabCatType.PCPhoneOther, "Misc / Mobile");
|
|
|
|
AddCategoryMapping(39, TorznabCatType.Other, "Misc / Bildung");
|
2018-03-25 15:03:10 +00:00
|
|
|
|
2018-09-05 16:00:05 +00:00
|
|
|
AddCategoryMapping(36, TorznabCatType.TVFOREIGN, "Englisch / Serien");
|
|
|
|
AddCategoryMapping(57, TorznabCatType.TVFOREIGN, "Englisch / Serienpacks");
|
2018-03-25 15:14:27 +00:00
|
|
|
AddCategoryMapping(37, TorznabCatType.MoviesForeign, "Englisch / Filme");
|
|
|
|
AddCategoryMapping(47, TorznabCatType.Books, "Englisch / eBooks");
|
|
|
|
AddCategoryMapping(48, TorznabCatType.Other, "Englisch / Bildung");
|
|
|
|
AddCategoryMapping(49, TorznabCatType.TVSport, "Englisch / Sport");
|
2020-02-09 02:35:16 +00:00
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-10-04 18:29:00 +00:00
|
|
|
ConfigData.LoadValuesFromJson(configJson);
|
|
|
|
var releases = await PerformQuery(new TorznabQuery());
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
await ConfigureIfOK(
|
2020-10-18 17:26:22 +00:00
|
|
|
string.Empty,
|
|
|
|
releases.Any(),
|
2020-10-04 18:29:00 +00:00
|
|
|
() => throw new Exception("Could not find any releases"));
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
return IndexerConfigurationStatus.Completed;
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var releases = new List<ReleaseInfo>();
|
2020-02-09 02:35:16 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
var queryCollection = new NameValueCollection {{"apikey", ConfigData.Key.Value}};
|
2020-03-21 23:06:22 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
queryCollection.Add("limit", "50"); // Default 30
|
|
|
|
//queryCollection.Add("ponly", true); // Torrents with products only
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
if (query.ImdbIDShort != null)
|
|
|
|
{
|
|
|
|
queryCollection.Add("imdbId", query.ImdbIDShort);
|
2020-10-05 18:41:27 +00:00
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchString))
|
2020-10-04 18:29:00 +00:00
|
|
|
{
|
2020-10-05 18:41:27 +00:00
|
|
|
// Suffix the first occurence of `s01` surrounded by whitespace with *
|
|
|
|
// That way we also search for single episodes in a whole season search
|
|
|
|
var regex = new Regex(@"(^|\s)(s\d{2})(\s|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
queryCollection.Add("searchstring", regex.Replace(searchString.Trim(), @"$1$2*$3"));
|
2017-11-13 08:42:25 +00:00
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
var cats = string.Join(",", MapTorznabCapsToTrackers(query));
|
|
|
|
if (!string.IsNullOrEmpty(cats))
|
2017-07-06 19:16:53 +00:00
|
|
|
{
|
2020-10-04 18:29:00 +00:00
|
|
|
queryCollection.Add("cats", cats);
|
2017-07-06 19:16:53 +00:00
|
|
|
}
|
|
|
|
|
2020-10-04 18:29:00 +00:00
|
|
|
var searchUrl = ApiBase + "/browse.php?" + queryCollection.GetQueryString();
|
|
|
|
var response = await RequestWithCookiesAsync(searchUrl, string.Empty);
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
try
|
|
|
|
{
|
2020-10-04 18:29:00 +00:00
|
|
|
CheckResponseStatus(response.Status, "browse");
|
|
|
|
|
|
|
|
var jsonContent = JObject.Parse(response.ContentString);
|
|
|
|
|
|
|
|
foreach (var row in jsonContent.Value<JArray>("rows"))
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-10-19 20:50:19 +00:00
|
|
|
var dateTime = new DateTime(1970,1,1,0,0,0,0,DateTimeKind.Utc);
|
2020-10-04 18:29:00 +00:00
|
|
|
|
|
|
|
var id = row.Value<string>("id");
|
|
|
|
var comments = new Uri(SiteLink + "details.php?id=" + id);
|
|
|
|
var seeders = row.Value<int>("seeders");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-03-26 22:15:28 +00:00
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
MinimumRatio = 1,
|
2020-10-04 18:29:00 +00:00
|
|
|
MinimumSeedTime = 96 * 60 * 60,
|
|
|
|
DownloadVolumeFactor = 1,
|
|
|
|
UploadVolumeFactor = 1,
|
2020-03-26 22:15:28 +00:00
|
|
|
Guid = comments,
|
2020-10-04 18:29:00 +00:00
|
|
|
Comments = comments,
|
|
|
|
Link = new Uri(SiteLink + "download.php?id=" + id),
|
|
|
|
Title = row.Value<string>("name"),
|
|
|
|
Category = MapTrackerCatToNewznab(row.Value<int>("category").ToString()),
|
|
|
|
PublishDate = dateTime.AddSeconds(row.Value<long>("added")).ToLocalTime(),
|
|
|
|
Size = row.Value<long>("size"),
|
|
|
|
Files = row.Value<long>("numfiles"),
|
2020-03-26 22:15:28 +00:00
|
|
|
Seeders = seeders,
|
2020-10-04 18:29:00 +00:00
|
|
|
Peers = seeders + row.Value<int>("leechers"),
|
|
|
|
Grabs = row.Value<int>("snatched"),
|
|
|
|
Imdb = row.Value<long?>("imdbId"),
|
|
|
|
TVDBId = row.Value<long?>("tvdbId"),
|
|
|
|
TMDb = row.Value<long?>("tmdbId")
|
2020-03-26 22:15:28 +00:00
|
|
|
};
|
2020-10-04 18:29:00 +00:00
|
|
|
|
|
|
|
var poster = row.Value<string>("poster");
|
|
|
|
if (!string.IsNullOrWhiteSpace(poster))
|
|
|
|
{
|
|
|
|
release.BannerUrl = new Uri(SiteLink + poster.Substring(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
var descriptions = new List<string>();
|
|
|
|
var title = row.Value<string>("title");
|
|
|
|
var titleOrigin = row.Value<string>("title_origin");
|
|
|
|
var year = row.Value<int?>("year");
|
|
|
|
var pid = row.Value<int?>("pid");
|
|
|
|
var releaseType = row.Value<string>("release_type");
|
|
|
|
var tags = row.Value<JArray>("tags");
|
|
|
|
var genres = row.Value<JArray>("genres");
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(title))
|
|
|
|
{
|
|
|
|
descriptions.Add("Title: " + title);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(titleOrigin))
|
|
|
|
{
|
|
|
|
descriptions.Add("Original Title: " + titleOrigin);
|
|
|
|
}
|
|
|
|
if (year > 0)
|
|
|
|
{
|
|
|
|
descriptions.Add("Year: " + year);
|
|
|
|
}
|
|
|
|
if (pid > 0)
|
|
|
|
{
|
|
|
|
descriptions.Add("Product-Link: " + SiteLink + "product.php?pid=" + pid);
|
|
|
|
}
|
|
|
|
if (genres != null && genres.Any())
|
|
|
|
{
|
|
|
|
descriptions.Add("Genres: " + string.Join(", ", genres));
|
|
|
|
}
|
|
|
|
if (tags != null && tags.Any())
|
|
|
|
{
|
|
|
|
descriptions.Add("Tags: " + string.Join(", ", tags));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(releaseType))
|
|
|
|
{
|
|
|
|
descriptions.Add("Release Type: " + releaseType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (descriptions.Any())
|
|
|
|
{
|
|
|
|
release.Description = string.Join(Environment.NewLine, descriptions);
|
|
|
|
}
|
2020-10-18 17:26:22 +00:00
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2020-10-04 18:29:00 +00:00
|
|
|
OnParseError(response.ContentString, ex);
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
2020-10-04 18:29:00 +00:00
|
|
|
|
|
|
|
public override async Task<byte[]> Download(Uri link)
|
|
|
|
{
|
|
|
|
var response = await RequestWithCookiesAsync(link.ToString() + "&apikey=" + ConfigData.Key.Value, string.Empty);
|
|
|
|
CheckResponseStatus(response.Status, "download");
|
|
|
|
return response.ContentBytes;
|
|
|
|
}
|
|
|
|
|
2020-10-19 20:50:19 +00:00
|
|
|
private static void CheckResponseStatus(HttpStatusCode status, string scope)
|
2020-10-04 18:29:00 +00:00
|
|
|
{
|
|
|
|
switch (status)
|
|
|
|
{
|
|
|
|
case HttpStatusCode.OK:
|
|
|
|
return;
|
|
|
|
case HttpStatusCode.BadRequest:
|
|
|
|
throw new Exception("Unknown or missing parameters");
|
|
|
|
case HttpStatusCode.Unauthorized:
|
|
|
|
throw new Exception("Wrong API-Key");
|
|
|
|
case HttpStatusCode.Forbidden:
|
|
|
|
throw new Exception("API-Key has no authorization for the endpoint / scope " + scope);
|
|
|
|
default:
|
|
|
|
throw new Exception("Unexpected response status code " + status);
|
|
|
|
}
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
}
|