[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

@@ -19,16 +19,16 @@ async function getCachedStreams(streams, apiKey) {
return undefined;
});
return available && streams
.reduce((cachedStreams, stream, index) => {
const isCached = available.response[index];
if (isCached) {
const streamTitleParts = stream.title.replace(/\n👤.*/s, '').split('\n');
const fileName = streamTitleParts[streamTitleParts.length - 1];
const fileIndex = streamTitleParts.length === 2 ? stream.fileIdx : null;
const encodedFileName = encodeURIComponent(fileName);
cachedStreams[stream.infoHash] = `${apiKey}/${stream.infoHash}/${encodedFileName}/${fileIndex}`;
}
return cachedStreams;
.reduce((mochStreams, stream, index) => {
const streamTitleParts = stream.title.replace(/\n👤.*/s, '').split('\n');
const fileName = streamTitleParts[streamTitleParts.length - 1];
const fileIndex = streamTitleParts.length === 2 ? stream.fileIdx : null;
const encodedFileName = encodeURIComponent(fileName);
mochStreams[stream.infoHash] = {
url: `${apiKey}/${stream.infoHash}/${encodedFileName}/${fileIndex}`,
cached: available.response[index]
};
return mochStreams;
}, {})
}