mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
improve sources for russian providers
This commit is contained in:
@@ -13,6 +13,14 @@ const ANIME_TRACKERS = [
|
|||||||
"http://share.camoe.cn:8080/announce",
|
"http://share.camoe.cn:8080/announce",
|
||||||
"http://t.nyaatracker.com:80/announce"
|
"http://t.nyaatracker.com:80/announce"
|
||||||
];
|
];
|
||||||
|
const RUSSIAN_TRACKERS = [
|
||||||
|
"udp://opentor.org:2710",
|
||||||
|
"http://retracker.local/announce",
|
||||||
|
"http://bt.t-ru.org/ann?magnet",
|
||||||
|
"http://bt2.t-ru.org/ann?magnet",
|
||||||
|
"http://bt3.t-ru.org/ann?magnet",
|
||||||
|
"http://bt4.t-ru.org/ann?magnet"
|
||||||
|
]
|
||||||
// Some trackers have limits on original torrent trackers,
|
// Some trackers have limits on original torrent trackers,
|
||||||
// where downloading ip has to seed the torrents for some amount of time,
|
// where downloading ip has to seed the torrents for some amount of time,
|
||||||
// thus it doesn't work on mochs.
|
// thus it doesn't work on mochs.
|
||||||
@@ -21,19 +29,25 @@ const ANIME_TRACKERS = [
|
|||||||
const LIMITED_PROVIDERS = [
|
const LIMITED_PROVIDERS = [
|
||||||
'Rutor'
|
'Rutor'
|
||||||
];
|
];
|
||||||
|
const ANIME_PROVIDERS = [
|
||||||
|
'HorribleSubs',
|
||||||
|
'NyaaSi',
|
||||||
|
'NyaaPantsu'
|
||||||
|
];
|
||||||
|
const RUSSIAN_PROVIDERS = [
|
||||||
|
'Rutor',
|
||||||
|
'Rutracker'
|
||||||
|
]
|
||||||
let BEST_TRACKERS = [];
|
let BEST_TRACKERS = [];
|
||||||
let ALL_TRACKERS = [];
|
let ALL_TRACKERS = [];
|
||||||
|
|
||||||
function getAllTrackers() {
|
|
||||||
return ALL_TRACKERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getMagnetLink(infoHash) {
|
async function getMagnetLink(infoHash) {
|
||||||
const torrent = await getTorrent(infoHash).catch(() => ({ infoHash }));
|
const torrent = await getTorrent(infoHash).catch(() => ({ infoHash }));
|
||||||
const torrentTrackers = !LIMITED_PROVIDERS.includes(torrent.provider)
|
const torrentTrackers = !LIMITED_PROVIDERS.includes(torrent.provider)
|
||||||
&& torrent.trackers && torrent.trackers.split(',');
|
&& torrent.trackers && torrent.trackers.split(',');
|
||||||
const animeTrackers = torrent.type === Type.ANIME ? ALL_TRACKERS : undefined;
|
const animeTrackers = torrent.type === Type.ANIME ? ALL_TRACKERS : undefined;
|
||||||
const trackers = torrentTrackers || animeTrackers;
|
const providerTrackers = RUSSIAN_PROVIDERS.includes(torrent.provider) && RUSSIAN_TRACKERS;
|
||||||
|
const trackers = unique([].concat(torrentTrackers).concat(animeTrackers).concat(providerTrackers));
|
||||||
|
|
||||||
return trackers
|
return trackers
|
||||||
? magnet.encode({ infoHash: infoHash, announce: trackers })
|
? magnet.encode({ infoHash: infoHash, announce: trackers })
|
||||||
@@ -60,4 +74,30 @@ async function getBestTrackers(retry = 2) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { initBestTrackers, getAllTrackers, getMagnetLink };
|
function getSources(trackersInput, infoHash) {
|
||||||
|
if (!trackersInput) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const trackers = Array.isArray(trackersInput) ? trackersInput : trackersInput.split(',');
|
||||||
|
return trackers.map(tracker => `tracker:${tracker}`).concat(`dht:${infoHash}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enrichStreamSources(stream) {
|
||||||
|
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
||||||
|
const provider = match && match[1];
|
||||||
|
if (ANIME_PROVIDERS.includes(provider)) {
|
||||||
|
const sources = getSources(ALL_TRACKERS, stream.infoHash);
|
||||||
|
return { ...stream, sources };
|
||||||
|
}
|
||||||
|
if (RUSSIAN_PROVIDERS.includes(provider)) {
|
||||||
|
const sources = unique([].concat(stream.sources).concat(getSources(RUSSIAN_TRACKERS, stream.infoHash)));
|
||||||
|
return { ...stream, sources };
|
||||||
|
}
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unique(array) {
|
||||||
|
return Array.from(new Set(array));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { initBestTrackers, getMagnetLink, getSources, enrichStreamSources };
|
||||||
@@ -1,17 +1,12 @@
|
|||||||
const titleParser = require('parse-torrent-title');
|
const titleParser = require('parse-torrent-title');
|
||||||
const { Type } = require('./types');
|
const { Type } = require('./types');
|
||||||
const { mapLanguages } = require('./languages');
|
const { mapLanguages } = require('./languages');
|
||||||
const { getAllTrackers } = require('./magnetHelper');
|
const { enrichStreamSources, getSources } = require('./magnetHelper');
|
||||||
|
|
||||||
const ADDON_NAME = 'Torrentio';
|
const ADDON_NAME = 'Torrentio';
|
||||||
const SIZE_DELTA = 0.02;
|
const SIZE_DELTA = 0.02;
|
||||||
const UNKNOWN_SIZE = 300000000;
|
const UNKNOWN_SIZE = 300000000;
|
||||||
const CAM_SOURCES = ['CAM', 'TeleSync', 'TeleCine', 'SCR'];
|
const CAM_SOURCES = ['CAM', 'TeleSync', 'TeleCine', 'SCR'];
|
||||||
const ANIME_PROVIDERS = [
|
|
||||||
'HorribleSubs',
|
|
||||||
'NyaaSi',
|
|
||||||
'NyaaPantsu'
|
|
||||||
].map(provider => provider.toLowerCase());
|
|
||||||
|
|
||||||
function toStreamInfo(record) {
|
function toStreamInfo(record) {
|
||||||
const torrentInfo = titleParser.parse(record.torrent.title);
|
const torrentInfo = titleParser.parse(record.torrent.title);
|
||||||
@@ -114,28 +109,10 @@ function applyStaticInfo(streams) {
|
|||||||
return streams.map(stream => enrichStaticInfo(stream));
|
return streams.map(stream => enrichStaticInfo(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
function enrichStreamSources(stream) {
|
|
||||||
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
|
||||||
const provider = match && match[1].toLowerCase();
|
|
||||||
if (ANIME_PROVIDERS.includes(provider)) {
|
|
||||||
const sources = getSources(getAllTrackers(), stream.infoHash);
|
|
||||||
return { ...stream, sources };
|
|
||||||
}
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
function enrichStaticInfo(stream) {
|
function enrichStaticInfo(stream) {
|
||||||
return enrichStreamSources(stream);
|
return enrichStreamSources(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSources(trackersInput, infoHash) {
|
|
||||||
if (!trackersInput) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const trackers = Array.isArray(trackersInput) ? trackersInput : trackersInput.split(',');
|
|
||||||
return trackers.map(tracker => `tracker:${tracker}`).concat(`dht:${infoHash}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBingeGroupParts(record, sameInfo, quality, torrentInfo, fileInfo) {
|
function getBingeGroupParts(record, sameInfo, quality, torrentInfo, fileInfo) {
|
||||||
if (record.torrent.type === Type.MOVIE) {
|
if (record.torrent.type === Type.MOVIE) {
|
||||||
const source = torrentInfo.source || fileInfo.source
|
const source = torrentInfo.source || fileInfo.source
|
||||||
|
|||||||
Reference in New Issue
Block a user