exoticaz: rewrite in c# to use the api. resolves #8873 (#8900)

This commit is contained in:
Diego Heras
2020-06-07 03:37:12 +02:00
committed by GitHub
parent d490b007ff
commit 03cc3f4f60
7 changed files with 171 additions and 163 deletions

View File

@@ -1,89 +0,0 @@
---
id: exoticaz
name: ExoticaZ
description: "ExoticaZ (YourExotic) is a Private Torrent Tracker for 3X"
language: en-us
type: private
encoding: UTF-8
links:
- https://exoticaz.to/
legacylinks:
- https://torrents.yourexotic.com/
caps:
categorymappings:
- {id: 1, cat: XXX, desc: "DVDRip"}
modes:
search: [q]
tv-search: [q]
movie-search: [q]
login:
path: login
method: form
inputs:
username_email: "{{ .Config.username }}"
password: "{{ .Config.password }}"
remember: on
captcha:
type: image
selector: img[alt="Captcha Image"]
input: captcha
error:
- selector: div.invalid-feedback
test:
selector: div.ratio-bar
search:
path: torrents
inputs:
# 0 any 1 filename 2 descr 3 files
in: 1
search: "{{ .Keywords }}"
category: 0
rows:
selector: div.table-responsive > table > tbody > tr
fields:
category:
text: 1
title:
selector: a.torrent-link
attribute: title
details:
selector: a.torrent-link
attribute: href
download:
selector: a[href*="/download/"]
attribute: href
banner:
selector: .screen-image
attribute: data-screens
filters:
- name: split
args: ["|", 0]
date:
selector: td:nth-last-child(5)
filters:
- name: append
args: " ago"
size:
selector: td:nth-last-child(4)
seeders:
selector: td:nth-last-child(3)
leechers:
selector: td:nth-last-child(2)
grabs:
selector: td:nth-last-child(1)
downloadvolumefactor:
case:
i[title="Free Download"]: 0
i[title="Half Download"]: 0.5
"*": 1
uploadvolumefactor:
case:
i.fa-gem: 2
"*": 1
# engine tbd

View File

@@ -34,6 +34,79 @@ namespace Jackett.Common.Indexers.Abstract
// hook to adjust the search term // hook to adjust the search term
protected virtual string GetSearchTerm(TorznabQuery query) => $"{query.SearchTerm} {query.GetEpisodeSearchString()}"; protected virtual string GetSearchTerm(TorznabQuery query) => $"{query.SearchTerm} {query.GetEpisodeSearchString()}";
// hook to adjust the search category
protected virtual List<KeyValuePair<string, string>> GetSearchQueryParameters(TorznabQuery query)
{
var categoryMapping = MapTorznabCapsToTrackers(query).Distinct().ToList();
var qc = new List<KeyValuePair<string, string>> // NameValueCollection don't support cat[]=19&cat[]=6
{
{"in", "1"},
{"type", categoryMapping.Any() ? categoryMapping.First() : "0"}
};
// resolution filter to improve the search
if (!query.Categories.Contains(TorznabCatType.Movies.ID) && !query.Categories.Contains(TorznabCatType.TV.ID) &&
!query.Categories.Contains(TorznabCatType.Audio.ID))
{
if (query.Categories.Contains(TorznabCatType.MoviesUHD.ID) || query.Categories.Contains(TorznabCatType.TVUHD.ID))
qc.Add("video_quality[]", "6"); // 2160p
if (query.Categories.Contains(TorznabCatType.MoviesHD.ID) || query.Categories.Contains(TorznabCatType.TVHD.ID))
{
qc.Add("video_quality[]", "2"); // 720p
qc.Add("video_quality[]", "7"); // 1080i
qc.Add("video_quality[]", "3"); // 1080p
}
if (query.Categories.Contains(TorznabCatType.MoviesSD.ID) || query.Categories.Contains(TorznabCatType.TVSD.ID))
qc.Add("video_quality[]", "1"); // SD
}
// note, search by tmdb and tvdb are supported too
// https://privatehd.to/api/v1/jackett/torrents?tmdb=1234
// https://privatehd.to/api/v1/jackett/torrents?tvdb=3653
if (query.IsImdbQuery)
qc.Add("imdb", query.ImdbID);
else
qc.Add("search", GetSearchTerm(query).Trim());
return qc;
}
// hook to adjust category parsing
protected virtual List<int> ParseCategories(TorznabQuery query, JToken row)
{
var cats = new List<int>();
var resolution = row.Value<string>("video_quality");
switch(row.Value<string>("type"))
{
case "Movie":
if (query.Categories.Contains(TorznabCatType.Movies.ID))
cats.Add(TorznabCatType.Movies.ID);
cats.Add(resolution switch
{
var res when _hdResolutions.Contains(res) => TorznabCatType.MoviesHD.ID,
"2160p" => TorznabCatType.MoviesUHD.ID,
_ => TorznabCatType.MoviesSD.ID
});
break;
case "TV-Show":
if (query.Categories.Contains(TorznabCatType.TV.ID))
cats.Add(TorznabCatType.TV.ID);
cats.Add(resolution switch
{
var res when _hdResolutions.Contains(res) => TorznabCatType.TVHD.ID,
"2160p" => TorznabCatType.TVUHD.ID,
_ => TorznabCatType.TVSD.ID
});
break;
case "Music":
cats.Add(TorznabCatType.Audio.ID);
break;
default:
throw new Exception("Error parsing category!");
}
return cats;
}
protected AvistazTracker(string link, string id, string name, string description, protected AvistazTracker(string link, string id, string name, string description,
IIndexerConfigurationService configService, WebClient client, Logger logger, IIndexerConfigurationService configService, WebClient client, Logger logger,
IProtectionService p, TorznabCapabilities caps) IProtectionService p, TorznabCapabilities caps)
@@ -51,16 +124,7 @@ without this configuration the torrent download does not work.<br/>You can find
{ {
Encoding = Encoding.UTF8; Encoding = Encoding.UTF8;
Language = "en-us"; Language = "en-us";
Type = "private";
AddCategoryMapping(1, TorznabCatType.Movies);
AddCategoryMapping(1, TorznabCatType.MoviesUHD);
AddCategoryMapping(1, TorznabCatType.MoviesHD);
AddCategoryMapping(1, TorznabCatType.MoviesSD);
AddCategoryMapping(2, TorznabCatType.TV);
AddCategoryMapping(2, TorznabCatType.TVUHD);
AddCategoryMapping(2, TorznabCatType.TVHD);
AddCategoryMapping(2, TorznabCatType.TVSD);
AddCategoryMapping(3, TorznabCatType.Audio);
} }
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson) public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
@@ -95,37 +159,7 @@ without this configuration the torrent download does not work.<br/>You can find
{ {
var releases = new List<ReleaseInfo>(); var releases = new List<ReleaseInfo>();
var categoryMapping = MapTorznabCapsToTrackers(query).Distinct().ToList(); var qc = GetSearchQueryParameters(query);
var qc = new List<KeyValuePair<string, string>> // NameValueCollection don't support cat[]=19&cat[]=6
{
{"in", "1"},
{"type", categoryMapping.Any() ? categoryMapping.First() : "0"} // type=0 => all categories
};
// resolution filter to improve the search
if (!query.Categories.Contains(TorznabCatType.Movies.ID) && !query.Categories.Contains(TorznabCatType.TV.ID) &&
!query.Categories.Contains(TorznabCatType.Audio.ID))
{
if (query.Categories.Contains(TorznabCatType.MoviesUHD.ID) || query.Categories.Contains(TorznabCatType.TVUHD.ID))
qc.Add("video_quality[]", "6"); // 2160p
if (query.Categories.Contains(TorznabCatType.MoviesHD.ID) || query.Categories.Contains(TorznabCatType.TVHD.ID))
{
qc.Add("video_quality[]", "2"); // 720p
qc.Add("video_quality[]", "7"); // 1080i
qc.Add("video_quality[]", "3"); // 1080p
}
if (query.Categories.Contains(TorznabCatType.MoviesSD.ID) || query.Categories.Contains(TorznabCatType.TVSD.ID))
qc.Add("video_quality[]", "1"); // SD
}
// note, search by tmdb and tvdb are supported too
// https://privatehd.to/api/v1/jackett/torrents?tmdb=1234
// https://privatehd.to/api/v1/jackett/torrents?tvdb=3653
if (query.IsImdbQuery)
qc.Add("imdb", query.ImdbID);
else
qc.Add("search", GetSearchTerm(query).Trim());
var episodeSearchUrl = SearchUrl + "?" + qc.GetQueryString(); var episodeSearchUrl = SearchUrl + "?" + qc.GetQueryString();
var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl, headers: GetSearchHeaders()); var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl, headers: GetSearchHeaders());
if (response.Status == HttpStatusCode.Unauthorized || response.Status == HttpStatusCode.PreconditionFailed) if (response.Status == HttpStatusCode.Unauthorized || response.Status == HttpStatusCode.PreconditionFailed)
@@ -172,36 +206,7 @@ without this configuration the torrent download does not work.<br/>You can find
description += $"<br/>Subtitles: {string.Join(", ", subtitleList)}"; description += $"<br/>Subtitles: {string.Join(", ", subtitleList)}";
} }
var cats = new List<int>(); var cats = ParseCategories(query, row);
var resolution = row.Value<string>("video_quality");
switch(row.Value<string>("type"))
{
case "Movie":
if (query.Categories.Contains(TorznabCatType.Movies.ID))
cats.Add(TorznabCatType.Movies.ID);
cats.Add(resolution switch
{
var res when _hdResolutions.Contains(res) => TorznabCatType.MoviesHD.ID,
"2160p" => TorznabCatType.MoviesUHD.ID,
_ => TorznabCatType.MoviesSD.ID
});
break;
case "TV-Show":
if (query.Categories.Contains(TorznabCatType.TV.ID))
cats.Add(TorznabCatType.TV.ID);
cats.Add(resolution switch
{
var res when _hdResolutions.Contains(res) => TorznabCatType.TVHD.ID,
"2160p" => TorznabCatType.TVUHD.ID,
_ => TorznabCatType.TVSD.ID
});
break;
case "Music":
cats.Add(TorznabCatType.Audio.ID);
break;
default:
throw new Exception("Error parsing category!");
}
var release = new ReleaseInfo var release = new ReleaseInfo
{ {

View File

@@ -24,7 +24,17 @@ namespace Jackett.Common.Indexers
client: wc, client: wc,
logger: l, logger: l,
p: ps) p: ps)
=> Type = "private"; {
AddCategoryMapping(1, TorznabCatType.Movies);
AddCategoryMapping(1, TorznabCatType.MoviesUHD);
AddCategoryMapping(1, TorznabCatType.MoviesHD);
AddCategoryMapping(1, TorznabCatType.MoviesSD);
AddCategoryMapping(2, TorznabCatType.TV);
AddCategoryMapping(2, TorznabCatType.TVUHD);
AddCategoryMapping(2, TorznabCatType.TVHD);
AddCategoryMapping(2, TorznabCatType.TVSD);
AddCategoryMapping(3, TorznabCatType.Audio);
}
// Avistaz has episodes without season. eg Running Man E323 // Avistaz has episodes without season. eg Running Man E323
protected override string GetSearchTerm(TorznabQuery query) => protected override string GetSearchTerm(TorznabQuery query) =>

View File

@@ -24,6 +24,16 @@ namespace Jackett.Common.Indexers
client: wc, client: wc,
logger: l, logger: l,
p: ps) p: ps)
=> Type = "private"; {
AddCategoryMapping(1, TorznabCatType.Movies);
AddCategoryMapping(1, TorznabCatType.MoviesUHD);
AddCategoryMapping(1, TorznabCatType.MoviesHD);
AddCategoryMapping(1, TorznabCatType.MoviesSD);
AddCategoryMapping(2, TorznabCatType.TV);
AddCategoryMapping(2, TorznabCatType.TVUHD);
AddCategoryMapping(2, TorznabCatType.TVHD);
AddCategoryMapping(2, TorznabCatType.TVSD);
AddCategoryMapping(3, TorznabCatType.Audio);
}
} }
} }

View File

@@ -0,0 +1,61 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Jackett.Common.Indexers.Abstract;
using Jackett.Common.Models;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
namespace Jackett.Common.Indexers
{
[ExcludeFromCodeCoverage]
public class ExoticaZ : AvistazTracker
{
public override string[] LegacySiteLinks { get; protected set; } =
{
"https://torrents.yourexotic.com/"
};
public ExoticaZ(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
: base(id: "exoticaz",
name: "ExoticaZ",
description: "ExoticaZ (YourExotic) is a Private Torrent Tracker for 3X",
link: "https://exoticaz.to/",
caps: new TorznabCapabilities(),
configService: configService,
client: wc,
logger: l,
p: ps)
{
AddCategoryMapping(1, TorznabCatType.XXXx264);
AddCategoryMapping(2, TorznabCatType.XXXPacks);
AddCategoryMapping(3, TorznabCatType.XXXPacks);
AddCategoryMapping(4, TorznabCatType.XXXPacks);
AddCategoryMapping(5, TorznabCatType.XXXDVD);
AddCategoryMapping(6, TorznabCatType.XXXOther);
AddCategoryMapping(7, TorznabCatType.XXXImageset);
}
protected override List<KeyValuePair<string, string>> GetSearchQueryParameters(TorznabQuery query)
{
var categoryMapping = MapTorznabCapsToTrackers(query).Distinct().ToList();
var qc = new List<KeyValuePair<string, string>> // NameValueCollection don't support cat[]=19&cat[]=6
{
{"in", "1"},
{"category", categoryMapping.Any() ? categoryMapping.First() : "0"},
{"search", GetSearchTerm(query).Trim()}
};
return qc;
}
protected override List<int> ParseCategories(TorznabQuery query, JToken row)
{
var cat = row.Value<JObject>("category").Properties().First().Name;
return MapTrackerCatToNewznab(cat).ToList();
}
}
}

View File

@@ -24,6 +24,16 @@ namespace Jackett.Common.Indexers
client: wc, client: wc,
logger: l, logger: l,
p: ps) p: ps)
=> Type = "private"; {
AddCategoryMapping(1, TorznabCatType.Movies);
AddCategoryMapping(1, TorznabCatType.MoviesUHD);
AddCategoryMapping(1, TorznabCatType.MoviesHD);
AddCategoryMapping(1, TorznabCatType.MoviesSD);
AddCategoryMapping(2, TorznabCatType.TV);
AddCategoryMapping(2, TorznabCatType.TVUHD);
AddCategoryMapping(2, TorznabCatType.TVHD);
AddCategoryMapping(2, TorznabCatType.TVSD);
AddCategoryMapping(3, TorznabCatType.Audio);
}
} }
} }

View File

@@ -306,6 +306,7 @@ namespace Jackett.Updater
"Definitions/eotforum.yml", "Definitions/eotforum.yml",
"Definitions/estrenosdtl.yml", "Definitions/estrenosdtl.yml",
"Definitions/evolutionpalace.yml", "Definitions/evolutionpalace.yml",
"Definitions/exoticaz.yml", // migrated to C#
"Definitions/extratorrentclone.yml", "Definitions/extratorrentclone.yml",
"Definitions/feedurneed.yml", "Definitions/feedurneed.yml",
"Definitions/freakstrackingsystem.yml", "Definitions/freakstrackingsystem.yml",