improve sources for russian providers

This commit is contained in:
TheBeastLT
2023-01-05 14:05:34 +02:00
parent 84507951e6
commit d5d528baa0
2 changed files with 47 additions and 30 deletions

View File

@@ -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