mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] return torrent trackers if available
This commit is contained in:
@@ -47,13 +47,14 @@ function toStreamInfo(record) {
|
|||||||
: `torrentio|${record.infoHash}`
|
: `torrentio|${record.infoHash}`
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return cleanOutputObject({
|
||||||
name: name,
|
name: name,
|
||||||
title: title,
|
title: title,
|
||||||
infoHash: record.infoHash,
|
infoHash: record.infoHash,
|
||||||
fileIdx: record.fileIndex,
|
fileIdx: record.fileIndex,
|
||||||
behaviorHints: record.torrent.type !== Type.MOVIE ? behaviorHints : null
|
behaviorHints: record.torrent.type !== Type.MOVIE ? behaviorHints : null,
|
||||||
};
|
sources: getSources(record.torrent.trackers, record.infoHash)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQuality(record, torrentInfo, fileInfo) {
|
function getQuality(record, torrentInfo, fileInfo) {
|
||||||
@@ -109,8 +110,7 @@ function enrichStreamSources(stream) {
|
|||||||
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
const match = stream.title.match(/⚙.* ([^ \n]+)/);
|
||||||
const provider = match && match[1].toLowerCase();
|
const provider = match && match[1].toLowerCase();
|
||||||
if (ANIME_PROVIDERS.includes(provider)) {
|
if (ANIME_PROVIDERS.includes(provider)) {
|
||||||
const infoHash = stream.infoHash;
|
const sources = getSources(getAllTrackers(), stream.infoHash);
|
||||||
const sources = getAllTrackers().map(tracker => `tracker:${tracker}`).concat(`dht:${infoHash}`);
|
|
||||||
return { ...stream, sources };
|
return { ...stream, sources };
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
@@ -120,4 +120,16 @@ 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 cleanOutputObject(object) {
|
||||||
|
return Object.fromEntries(Object.entries(object).filter(([_, v]) => v != null));
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = { toStreamInfo, applyStaticInfo };
|
module.exports = { toStreamInfo, applyStaticInfo };
|
||||||
|
|||||||
Reference in New Issue
Block a user