[addon] adds debrid download link option an logic

This commit is contained in:
TheBeastLT
2020-05-10 21:33:53 +02:00
parent 3662eda2bc
commit 0c8c813756
5 changed files with 82 additions and 35 deletions

View File

@@ -22,13 +22,15 @@ async function getCachedStreams(streams, apiKey) {
return undefined;
});
return available && streams
.reduce((cachedStreams, stream) => {
.reduce((mochStreams, stream) => {
const cachedEntry = available[stream.infoHash];
const cachedIds = _getCachedFileIds(stream.fileIdx, cachedEntry).join(',');
if (cachedIds.length) {
cachedStreams[stream.infoHash] = `${apiKey}/${stream.infoHash}/${cachedIds}/${stream.fileIdx}`;
}
return cachedStreams;
const cachedIds = _getCachedFileIds(stream.fileIdx, cachedEntry);
const cachedIdsString = cachedIds.length ? cachedIds.join(',') : null;
mochStreams[stream.infoHash] = {
url: `${apiKey}/${stream.infoHash}/${cachedIdsString}/${stream.fileIdx}`,
cached: !!cachedIdsString
};
return mochStreams;
}, {})
}