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:
@@ -1,17 +1,12 @@
|
||||
const titleParser = require('parse-torrent-title');
|
||||
const { Type } = require('./types');
|
||||
const { mapLanguages } = require('./languages');
|
||||
const { getAllTrackers } = require('./magnetHelper');
|
||||
const { enrichStreamSources, getSources } = require('./magnetHelper');
|
||||
|
||||
const ADDON_NAME = 'Torrentio';
|
||||
const SIZE_DELTA = 0.02;
|
||||
const UNKNOWN_SIZE = 300000000;
|
||||
const CAM_SOURCES = ['CAM', 'TeleSync', 'TeleCine', 'SCR'];
|
||||
const ANIME_PROVIDERS = [
|
||||
'HorribleSubs',
|
||||
'NyaaSi',
|
||||
'NyaaPantsu'
|
||||
].map(provider => provider.toLowerCase());
|
||||
|
||||
function toStreamInfo(record) {
|
||||
const torrentInfo = titleParser.parse(record.torrent.title);
|
||||
@@ -114,28 +109,10 @@ function applyStaticInfo(streams) {
|
||||
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) {
|
||||
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) {
|
||||
if (record.torrent.type === Type.MOVIE) {
|
||||
const source = torrentInfo.source || fileInfo.source
|
||||
|
||||
Reference in New Issue
Block a user