mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
danishbytes: switch to yaml. resolves #13010
This commit is contained in:
116
src/Jackett.Common/Definitions/danishbytes-api.yml
Normal file
116
src/Jackett.Common/Definitions/danishbytes-api.yml
Normal file
@@ -0,0 +1,116 @@
|
||||
---
|
||||
id: danishbytes-api
|
||||
name: DanishBytes (API)
|
||||
description: "DanishBytes is a Private Danish Tracker"
|
||||
language: en-US
|
||||
type: private
|
||||
encoding: UTF-8
|
||||
links:
|
||||
- https://danishbytes.club/
|
||||
- https://danishbytes2.org/
|
||||
- https://dbytes.org/
|
||||
- https://danishbytes.art/
|
||||
legacylinks:
|
||||
- https://danishbytes.org/
|
||||
|
||||
caps:
|
||||
categorymappings:
|
||||
- {id: 1, cat: Movies, desc: "Movies"}
|
||||
- {id: 2, cat: TV, desc: "TV"}
|
||||
- {id: 3, cat: Audio, desc: "Sound"}
|
||||
- {id: 4, cat: PC/Games, desc: "Games"}
|
||||
- {id: 5, cat: PC/0day, desc: "Appz"}
|
||||
- {id: 8, cat: Books, desc: "Bookz"}
|
||||
|
||||
modes:
|
||||
search: [q]
|
||||
tv-search: [q, season, ep, imdbid, tvdbid]
|
||||
movie-search: [q, imdbid, tmdbid]
|
||||
music-search: [q]
|
||||
book-search: [q]
|
||||
|
||||
settings:
|
||||
- name: apikey
|
||||
type: text
|
||||
label: APIKey
|
||||
- name: info_apikey
|
||||
type: info
|
||||
label: About your API key
|
||||
default: "Find or Generate a new API Token by accessing your <a href=\"https://danishbytes.club/\" target =_blank>DanishBytes</a> account <i>My Security</i> page and clicking on the <b>API Token</b> tab."
|
||||
- name: rsskey
|
||||
type: text
|
||||
label: RSSKey
|
||||
- name: info_rsskey
|
||||
type: info
|
||||
label: About your RSS key
|
||||
default: "Find or Generate a new RSS key by accessing your <a href=\"https://danishbytes.club/\" target =_blank>DanishBytes</a> account <i>My Security</i> page and clicking on the <b>RSS Key (RID)</b> tab."
|
||||
|
||||
login:
|
||||
path: /api/torrents
|
||||
method: get
|
||||
inputs:
|
||||
api_token: "{{ .Config.apikey }}"
|
||||
error:
|
||||
- selector: a[href*="/login"]
|
||||
message:
|
||||
text: "The API key was not accepted by {{ .Config.sitelink }}."
|
||||
|
||||
search:
|
||||
paths:
|
||||
- path: "/api/torrents/v2/filter?api_token={{ .Config.apikey }}&search={{ .Keywords }}{{ if .Query.IMDBIDShort }}&imdb={{ .Query.IMDBIDShort }}{{ else }}{{ end }}{{ if .Query.TMDBID }}&tmdb={{ .Query.TMDBID }}{{ else }}{{ end }}{{ if .Query.TVDBID }}&tvdb={{ .Query.TVDBID }}{{ else }}{{ end }}{{ range .Categories }}&categories[]={{.}}{{end}}"
|
||||
response:
|
||||
type: json
|
||||
|
||||
rows:
|
||||
selector: torrents
|
||||
count:
|
||||
selector: $.resultsCount
|
||||
|
||||
fields:
|
||||
id:
|
||||
selector: .id
|
||||
category:
|
||||
selector: category_id
|
||||
title:
|
||||
selector: name
|
||||
details:
|
||||
text: "{{ .Config.sitelink }}torrents/{{ .Result.id }}"
|
||||
download:
|
||||
text: "{{ .Config.sitelink }}torrent/download/{{ .Result.id }}.{{ .Config.rsskey }}"
|
||||
poster:
|
||||
selector: poster_image
|
||||
imdbid:
|
||||
selector: imdb
|
||||
tmdbid:
|
||||
selector: tmdb
|
||||
tvdbid:
|
||||
selector: tvdb
|
||||
seeders:
|
||||
selector: seeders
|
||||
leechers:
|
||||
selector: leechers
|
||||
grabs:
|
||||
selector: times_completed
|
||||
date:
|
||||
# 2022-02-28T19:09:44.000000Z
|
||||
selector: created_at
|
||||
size:
|
||||
selector: size
|
||||
downloadvolumefactor:
|
||||
# api returns 0=false, 1=true
|
||||
selector: free
|
||||
case:
|
||||
0: 1 # not free
|
||||
1: 0 # freeleech
|
||||
uploadvolumefactor:
|
||||
# api returns 0=false, 1=true
|
||||
selector: doubleup
|
||||
case:
|
||||
0: 1 # normal
|
||||
1: 2 # double
|
||||
minimumratio:
|
||||
text: 1.0
|
||||
minimumseedtime:
|
||||
# 2 day (as seconds = 2 x 24 x 60 x 60)
|
||||
text: 172800
|
||||
# json DBy v0.95
|
@@ -1,168 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
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 Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using WebClient = Jackett.Common.Utils.Clients.WebClient;
|
||||
|
||||
namespace Jackett.Common.Indexers
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DanishBytes : BaseWebIndexer
|
||||
{
|
||||
private string SearchURl => SiteLink + "api/torrents/v2/filter";
|
||||
|
||||
private new ConfigurationDataAPIKey configData => (ConfigurationDataAPIKey)base.configData;
|
||||
|
||||
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
||||
"https://danishbytes.club/",
|
||||
"https://danishbytes2.org/"
|
||||
};
|
||||
|
||||
public override string[] LegacySiteLinks { get; protected set; } = {
|
||||
"https://danishbytes.org/"
|
||||
};
|
||||
|
||||
public DanishBytes(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
|
||||
ICacheService cs)
|
||||
: base(id: "danishbytes",
|
||||
name: "DanishBytes",
|
||||
description: "DanishBytes is a Private Danish Tracker",
|
||||
link: "https://danishbytes.club/",
|
||||
caps: new TorznabCapabilities
|
||||
{
|
||||
LimitsDefault = 25,
|
||||
LimitsMax = 25,
|
||||
TvSearchParams = new List<TvSearchParam>
|
||||
{
|
||||
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId, TvSearchParam.TvdbId
|
||||
},
|
||||
MovieSearchParams = new List<MovieSearchParam>
|
||||
{
|
||||
MovieSearchParam.Q, MovieSearchParam.ImdbId, MovieSearchParam.TmdbId
|
||||
},
|
||||
MusicSearchParams = new List<MusicSearchParam>
|
||||
{
|
||||
MusicSearchParam.Q
|
||||
},
|
||||
BookSearchParams = new List<BookSearchParam>
|
||||
{
|
||||
BookSearchParam.Q
|
||||
}
|
||||
},
|
||||
configService: configService,
|
||||
client: wc,
|
||||
logger: l,
|
||||
p: ps,
|
||||
cacheService: cs,
|
||||
configData: new ConfigurationDataAPIKey())
|
||||
|
||||
{
|
||||
Encoding = Encoding.UTF8;
|
||||
Language = "en-US";
|
||||
Type = "private";
|
||||
|
||||
AddCategoryMapping("1", TorznabCatType.Movies, "Movies");
|
||||
AddCategoryMapping("2", TorznabCatType.TV, "TV");
|
||||
AddCategoryMapping("3", TorznabCatType.Audio, "Music");
|
||||
AddCategoryMapping("4", TorznabCatType.PCGames, "Games");
|
||||
AddCategoryMapping("5", TorznabCatType.PC0day, "Appz");
|
||||
AddCategoryMapping("8", TorznabCatType.Books, "Bookz");
|
||||
}
|
||||
|
||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
LoadValuesFromJson(configJson);
|
||||
|
||||
await PerformQuery(new TorznabQuery()); // throws exception if there is an error
|
||||
|
||||
IsConfigured = true;
|
||||
SaveConfig();
|
||||
return IndexerConfigurationStatus.Completed;
|
||||
}
|
||||
|
||||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var releases = new List<ReleaseInfo>();
|
||||
|
||||
var qc = new NameValueCollection
|
||||
{
|
||||
{"search", query.GetQueryString()},
|
||||
{"api_token", configData.Key.Value},
|
||||
};
|
||||
|
||||
if (query.IsImdbQuery)
|
||||
qc.Add("imdb", query.ImdbID);
|
||||
if (query.IsTvdbSearch)
|
||||
qc.Add("tvdb", query.TvdbID.ToString());
|
||||
if (query.IsTmdbQuery)
|
||||
qc.Add("tmdb", query.TmdbID.ToString());
|
||||
|
||||
var requestUrl = SearchURl;
|
||||
var searchUrl = requestUrl + "?" + qc.GetQueryString();
|
||||
|
||||
foreach (var cat in MapTorznabCapsToTrackers(query))
|
||||
searchUrl += $"&categories[]={cat}";
|
||||
|
||||
var results = await RequestWithCookiesAsync(searchUrl);
|
||||
if (results.Status != HttpStatusCode.OK)
|
||||
throw new Exception($"Error code: {results.Status}");
|
||||
|
||||
try
|
||||
{
|
||||
var jsonContent = JObject.Parse(results.ContentString);
|
||||
var rsskey = jsonContent.Value<string>("rsskey");
|
||||
foreach (var item in jsonContent.Value<JArray>("torrents"))
|
||||
{
|
||||
var torrent = item.ToObject<Torrent>();
|
||||
var release = new ReleaseInfo
|
||||
{
|
||||
Title = torrent.name,
|
||||
Details = new Uri($"{SiteLink}torrents/{torrent.id}"),
|
||||
Link = new Uri($"{SiteLink}torrent/download/{torrent.id}.{rsskey}"),
|
||||
PublishDate = torrent.created_at,
|
||||
Category = MapTrackerCatToNewznab(torrent.category_id),
|
||||
Size = torrent.size,
|
||||
Seeders = torrent.seeders,
|
||||
Peers = torrent.leechers + torrent.seeders,
|
||||
Grabs = torrent.times_completed,
|
||||
DownloadVolumeFactor = torrent.free ? 0 : 1,
|
||||
UploadVolumeFactor = torrent.doubleup ? 2 : 1
|
||||
};
|
||||
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnParseError(results.ContentString, ex);
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
private class Torrent
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; }
|
||||
public long size { get; set; }
|
||||
public int leechers { get; set; }
|
||||
public int seeders { get; set; }
|
||||
public int times_completed { get; set; }
|
||||
public string category_id { get; set; }
|
||||
public bool free { get; set; }
|
||||
public bool doubleup { get; set; }
|
||||
public DateTime created_at { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -306,7 +306,6 @@ namespace Jackett.Updater
|
||||
"Definitions/czteam.yml",
|
||||
"Definitions/cztorrent.yml",
|
||||
"Definitions/darmowetorenty.yml", // migrated to C#
|
||||
"Definitions/danishbytes.yml", // migrated to C#
|
||||
"Definitions/DasUnerwartete.yml",
|
||||
"Definitions/datascene.yml", // switch to *-API #8682
|
||||
"Definitions/demonsite.yml",
|
||||
|
Reference in New Issue
Block a user