digitalcore: C# -> yaml (#12469)

This commit is contained in:
ilike2burnthing
2021-10-27 12:28:57 +01:00
committed by GitHub
parent 5d83d5c62a
commit a735f3cc0c
2 changed files with 222 additions and 245 deletions

View File

@@ -0,0 +1,222 @@
---
id: digitalcore
name: DigitalCore
description: "DigitalCore is a Private Torrent Tracker for MOVIES / TV / GENERAL"
language: en-US
type: private
encoding: UTF-8
links:
- https://digitalcore.club/
caps:
categorymappings:
- {id: 1, cat: Movies/DVD, desc: Movies/DVDR}
- {id: 2, cat: Movies/SD, desc: Movies/SD}
- {id: 3, cat: Movies/BluRay, desc: Movies/BluRay}
- {id: 4, cat: Movies/UHD, desc: Movies/4K}
- {id: 5, cat: Movies/HD, desc: Movies/720p}
- {id: 6, cat: Movies/HD, desc: Movies/1080p}
- {id: 7, cat: Movies/HD, desc: Movies/PACKS}
- {id: 8, cat: TV/HD, desc: TV/720p}
- {id: 9, cat: TV/HD, desc: TV/1080p}
- {id: 10, cat: TV/SD, desc: TV/SD}
- {id: 11, cat: TV/SD, desc: TV/DVDR}
- {id: 12, cat: TV/HD, desc: TV/PACKS}
- {id: 13, cat: TV/UHD, desc: TV/4K}
- {id: 14, cat: TV/HD, desc: TV/BluRay}
- {id: 17, cat: Other, desc: Unknown}
- {id: 18, cat: PC/0day, desc: Apps/0day}
- {id: 20, cat: PC/ISO, desc: Apps/PC}
- {id: 21, cat: PC/Mac, desc: Apps/Mac}
- {id: 33, cat: PC, desc: Apps/Tutorials}
- {id: 22, cat: Audio/MP3, desc: Music/MP3}
- {id: 23, cat: Audio/Lossless, desc: Music/FLAC}
- {id: 24, cat: Audio/Video, desc: Music/MTV}
- {id: 29, cat: Audio, desc: Music/PACKS}
- {id: 25, cat: PC/Games, desc: Games/PC}
- {id: 26, cat: Console, desc: Games/NSW}
- {id: 27, cat: PC/Mac, desc: Games/Mac}
- {id: 28, cat: Books/EBook, desc: Ebooks}
- {id: 30, cat: XXX/SD, desc: XXX/SD}
- {id: 31, cat: XXX, desc: XXX/HD}
- {id: 32, cat: XXX/UHD, desc: XXX/4K}
- {id: 35, cat: XXX/SD, desc: XXX/Movies/SD}
- {id: 36, cat: XXX, desc: XXX/Movies/HD}
- {id: 37, cat: XXX/UHD, desc: XXX/Movies/4K}
- {id: 34, cat: XXX/ImageSet, desc: XXX/Imagesets}
modes:
search: [q]
tv-search: [q, season, ep, imdbid]
movie-search: [q, imdbid]
music-search: [q]
book-search: [q]
settings:
- name: cookie
type: text
label: Cookie
- name: info
type: info
label: How to get the Cookie
default: "<ol><li>Login to this tracker with your browser<li>Open the <b>DevTools</b> panel by pressing <b>F12</b><li>Select the <b>Network</b> tab<li>Click on the <b>Doc</b> button (Chrome Browser) or <b>HTML</b> button (FireFox)<li>Refresh the page by pressing <b>F5</b><li>Click on the first row entry<li>Select the <b>Headers</b> tab on the Right panel<li>Find <b>'cookie:'</b> in the <b>Request Headers</b> section<li><b>Select</b> and <b>Copy</b> the whole cookie string <i>(everything after 'cookie: ')</i> and <b>Paste</b> here.</ol>"
- name: freeleech
type: checkbox
label: Search freeleech only
default: false
- name: sort
type: select
label: Sort requested from site
default: d
options:
d: created
up: seeders
s: size
n: title
- name: type
type: select
label: Order requested from site
default: desc
options:
desc: desc
asc: asc
login:
method: cookie
inputs:
cookie: "{{ .Config.cookie }}"
search:
paths:
- path: api/v1/torrents
response:
type: json
noResultsMessage: ""
inputs:
$raw: "{{ range .Categories }}categories[]={{.}}&{{end}}"
dead: true
extendedDead: true
extendedSearch: false
freeleech: "{{ if .Config.freeleech }}true{{ else }}false{{ end }}"
index: 0
limit: 100
order: "{{ .Config.type }}"
page: search
searchText: "{{ if .Query.IMDBID }}{{ .Query.IMDBID }}{{ else }}{{ .Keywords }}{{ end }}"
section: all
sort: "{{ .Config.sort }}"
stereoscopic: false
watchview: false
rows:
selector: $
fields:
category:
selector: category
title:
selector: name
id:
selector: id
details:
text: "{{ .Config.sitelink }}torrent/{{ .Result.id }}/"
download:
text: "{{ .Config.sitelink }}api/v1/torrents/download/{{ .Result.id }}"
imdbid:
selector: imdbid2
imdbidfull:
optional: true
selector: imdbid2
posternormal:
optional: true
selector: firstpic
posterimdb:
optional: true
text: "{{ if .Result.imdbid }}{{ .Config.sitelink }}img/imdb/{{ .Result.imdbidfull }}.jpg{{ else }}{{ end }}"
poster:
text: "{{ if .Result.posterimdb }}{{ .Result.posterimdb }}{{ else }}{{ .Result.posternormal }}{{ end }}"
date:
# 2021-10-27 12:07:22
selector: added
filters:
- name: append
args: " +01:00" # CET
- name: dateparse
args: "2006-01-02 15:04:05 -07:00"
size:
selector: size
files:
selector: numfiles
grabs:
selector: times_completed
seeders:
selector: seeders
leechers:
selector: leechers
downloadvolumefactor:
# api returns 0=false, 1=true
selector: frileech
case:
0: 1 # not free
1: 0 # freeleech
uploadvolumefactor:
text: 1
minimumratio:
text: 1.1
minimumseedtime:
# 5 days (as seconds = 5 x 24 x 60 x 60)
text: 432000
titledesc:
optional: true
selector: title
yeardesc:
optional: true
selector: year
genresdesc:
optional: true
selector: genres
taglinedesc:
optional: true
selector: tagline
castdesc:
optional: true
selector: cast
ratingdesc:
optional: true
selector: rating
filters:
- name: re_replace
args: ["0", ""]
sectiondesc:
optional: true
selector: section
predatedesc:
selector: preDate
filters:
- name: re_replace
args: ["0000-00-00 00:00:00", ""]
p2ptag:
selector: p2p
case:
0: ""
1: P2P
packtag:
selector: pack
case:
0: ""
1: Pack
reqidtag:
selector: reqid
case:
0: ""
"*": Request
tagdesc:
optional: true
text: "{{ if .Result.p2ptag }}{{ .Result.p2ptag }}, {{ else }}{{ end }}{{ if .Result.packtag }}{{ .Result.packtag }}, {{ else }}{{ end }}{{ if .Result.reqidtag }}{{ .Result.reqidtag }}{{ else }}{{ end }}"
filters:
- name: regexp
args: "(.+?), $"
description:
text: "{{ if .Result.titledesc }}Title: {{ .Result.titledesc }}</br>{{ else }}{{ end }}{{ if .Result.yeardesc }}Year: {{ .Result.yeardesc }}</br>{{ else }}{{ end }}{{ if .Result.genresdesc }}Genres: {{ .Result.genresdesc }}</br>{{ else }}{{ end }}{{ if .Result.taglinedesc }}Tagline: {{ .Result.taglinedesc }}</br>{{ else }}{{ end }}{{ if .Result.castdesc }}Cast: {{ .Result.castdesc }}</br>{{ else }}{{ end }}{{ if .Result.ratingdesc }}Rating: {{ .Result.ratingdesc }}</br>{{ else }}{{ end }}{{ if .Result.tagdesc }}Tags: {{ .Result.tagdesc }}</br>{{ else }}{{ end }}{{ if .Result.predatedesc }}PRE: {{ .Result.predatedesc }}</br>{{ else }}{{ end }}{{ if .Result.sectiondesc }}Section: {{ .Result.sectiondesc }}{{ else }}{{ end }}"
# json rartracker api v1

View File

@@ -1,245 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
namespace Jackett.Common.Indexers
{
[ExcludeFromCodeCoverage]
public class DigitalCore : BaseWebIndexer
{
private string SearchUrl => SiteLink + "api/v1/torrents";
private string LoginUrl => SiteLink + "api/v1/auth";
private new ConfigurationDataCookie configData
{
get => (ConfigurationDataCookie)base.configData;
set => base.configData = value;
}
public DigitalCore(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps,
ICacheService cs)
: base(id: "digitalcore",
name: "DigitalCore",
description: "DigitalCore is a Private Torrent Tracker for MOVIES / TV / GENERAL",
link: "https://digitalcore.club/",
caps: new TorznabCapabilities
{
TvSearchParams = new List<TvSearchParam>
{
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
},
MovieSearchParams = new List<MovieSearchParam>
{
MovieSearchParam.Q, MovieSearchParam.ImdbId
},
MusicSearchParams = new List<MusicSearchParam>
{
MusicSearchParam.Q
},
BookSearchParams = new List<BookSearchParam>
{
BookSearchParam.Q
}
},
configService: configService,
client: w,
logger: l,
p: ps,
cacheService: cs,
configData: new ConfigurationDataCookie())
{
Encoding = Encoding.UTF8;
Language = "en-US";
Type = "private";
AddCategoryMapping(1, TorznabCatType.MoviesDVD, "Movies/DVDR");
AddCategoryMapping(2, TorznabCatType.MoviesSD, "Movies/SD");
AddCategoryMapping(3, TorznabCatType.MoviesBluRay, "Movies/BluRay");
AddCategoryMapping(4, TorznabCatType.MoviesUHD, "Movies/4K");
AddCategoryMapping(5, TorznabCatType.MoviesHD, "Movies/720p");
AddCategoryMapping(6, TorznabCatType.MoviesHD, "Movies/1080p");
AddCategoryMapping(7, TorznabCatType.MoviesHD, "Movies/PACKS");
AddCategoryMapping(8, TorznabCatType.TVHD, "TV/720p");
AddCategoryMapping(9, TorznabCatType.TVHD, "TV/1080p");
AddCategoryMapping(10, TorznabCatType.TVSD, "TV/SD");
AddCategoryMapping(11, TorznabCatType.TVSD, "TV/DVDR");
AddCategoryMapping(12, TorznabCatType.TVHD, "TV/PACKS");
AddCategoryMapping(13, TorznabCatType.TVUHD, "TV/4K");
AddCategoryMapping(14, TorznabCatType.TVHD, "TV/BluRay");
AddCategoryMapping(17, TorznabCatType.Other, "Unknown");
AddCategoryMapping(18, TorznabCatType.PC0day, "Apps/0day");
AddCategoryMapping(20, TorznabCatType.PCISO, "Apps/PC");
AddCategoryMapping(21, TorznabCatType.PCMac, "Apps/Mac");
AddCategoryMapping(33, TorznabCatType.PC, "Apps/Tutorials");
AddCategoryMapping(22, TorznabCatType.AudioMP3, "Music/MP3");
AddCategoryMapping(23, TorznabCatType.AudioLossless, "Music/FLAC");
AddCategoryMapping(24, TorznabCatType.AudioVideo, "Music/MTV");
AddCategoryMapping(29, TorznabCatType.Audio, "Music/PACKS");
AddCategoryMapping(25, TorznabCatType.PCGames, "Games/PC");
AddCategoryMapping(26, TorznabCatType.Console, "Games/NSW");
AddCategoryMapping(27, TorznabCatType.PCMac, "Games/Mac");
AddCategoryMapping(28, TorznabCatType.BooksEBook, "Ebooks");
AddCategoryMapping(30, TorznabCatType.XXXSD, "XXX/SD");
AddCategoryMapping(31, TorznabCatType.XXX, "XXX/HD");
AddCategoryMapping(32, TorznabCatType.XXXUHD, "XXX/4K");
AddCategoryMapping(35, TorznabCatType.XXXSD, "XXX/Movies/SD");
AddCategoryMapping(36, TorznabCatType.XXX, "XXX/Movies/HD");
AddCategoryMapping(37, TorznabCatType.XXXUHD, "XXX/Movies/4K");
AddCategoryMapping(34, TorznabCatType.XXXImageSet, "XXX/Imagesets");
}
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{
LoadValuesFromJson(configJson);
// TODO: implement captcha
CookieHeader = configData.Cookie.Value;
try
{
var results = await PerformQuery(new TorznabQuery());
if (results.Count() == 0)
{
throw new Exception("Found 0 results in the tracker");
}
IsConfigured = true;
SaveConfig();
return IndexerConfigurationStatus.Completed;
}
catch (Exception e)
{
IsConfigured = false;
throw new Exception("Your cookie did not work: " + e.Message);
}
}
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var queryCollection = new NameValueCollection();
var searchString = query.GetQueryString();
var searchUrl = SearchUrl;
queryCollection.Add("extendedSearch", "false");
queryCollection.Add("freeleech", "false");
queryCollection.Add("index", "0");
queryCollection.Add("limit", "100");
queryCollection.Add("order", "desc");
queryCollection.Add("page", "search");
if (query.ImdbID != null)
queryCollection.Add("searchText", query.ImdbID);
else
queryCollection.Add("searchText", searchString);
queryCollection.Add("sort", "d");
queryCollection.Add("section", "all");
queryCollection.Add("stereoscopic", "false");
queryCollection.Add("watchview", "false");
searchUrl += "?" + queryCollection.GetQueryString();
foreach (var cat in MapTorznabCapsToTrackers(query))
searchUrl += "&categories[]=" + cat;
var results = await RequestWithCookiesAsync(searchUrl, referer: SiteLink);
try
{
//var json = JArray.Parse(results.Content);
var json = JsonConvert.DeserializeObject<dynamic>(results.ContentString);
foreach (var row in json ?? Enumerable.Empty<dynamic>())
{
var release = new ReleaseInfo();
var descriptions = new List<string>();
var tags = new List<string>();
release.MinimumRatio = 1.1;
release.MinimumSeedTime = 432000; // 120 hours
release.Title = row.name;
release.Category = MapTrackerCatToNewznab(row.category.ToString());
release.Size = row.size;
release.Seeders = row.seeders;
release.Peers = row.leechers + release.Seeders;
release.PublishDate = DateTime.ParseExact(row.added.ToString() + " +01:00", "yyyy-MM-dd HH:mm:ss zzz", CultureInfo.InvariantCulture);
release.Files = row.numfiles;
release.Grabs = row.times_completed;
release.Details = new Uri(SiteLink + "torrent/" + row.id.ToString() + "/");
release.Guid = release.Details;
release.Link = new Uri(SiteLink + "api/v1/torrents/download/" + row.id.ToString());
if (row.frileech == 1)
release.DownloadVolumeFactor = 0;
else
release.DownloadVolumeFactor = 1;
release.UploadVolumeFactor = 1;
if (!string.IsNullOrWhiteSpace(row.firstpic.ToString()))
{
release.Poster = (row.firstpic);
}
if (row.imdbid2 != null && row.imdbid2.ToString().StartsWith("tt"))
{
release.Imdb = ParseUtil.CoerceLong(row.imdbid2.ToString().Substring(2));
descriptions.Add("Title: " + row.title);
descriptions.Add("Year: " + row.year);
descriptions.Add("Genres: " + row.genres);
descriptions.Add("Tagline: " + row.tagline);
descriptions.Add("Cast: " + row.cast);
descriptions.Add("Rating: " + row.rating);
//descriptions.Add("Plot: " + row.plot);
release.Poster = new Uri(SiteLink + "img/imdb/" + row.imdbid2 + ".jpg");
}
if ((int)row.p2p == 1)
tags.Add("P2P");
if ((int)row.pack == 1)
tags.Add("Pack");
if ((int)row.reqid != 0)
tags.Add("Request");
if (tags.Count > 0)
descriptions.Add("Tags: " + string.Join(", ", tags));
var preDate = row.preDate.ToString();
if (!string.IsNullOrWhiteSpace(preDate) && preDate != "1970-01-01 01:00:00")
{
descriptions.Add("Pre: " + preDate);
}
descriptions.Add("Section: " + row.section);
release.Description = string.Join("<br>\n", descriptions);
releases.Add(release);
}
}
catch (Exception ex)
{
OnParseError(results.ContentString, ex);
}
return releases;
}
}
}