From ba65d15b373ffb68ff318b609d47c6b5ff3641cd Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Fri, 15 Mar 2024 20:25:57 +0200 Subject: [PATCH] improve offcloud link resolving --- addon/moch/offcloud.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addon/moch/offcloud.js b/addon/moch/offcloud.js index a7597af..76d01aa 100644 --- a/addon/moch/offcloud.js +++ b/addon/moch/offcloud.js @@ -27,10 +27,9 @@ export async function getCachedStreams(streams, apiKey) { const isCached = available.includes(stream.infoHash); 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}@${stream.fileIdx}`] = { - url: `${apiKey}/${stream.infoHash}/${encodedFileName}/${fileIndex}`, + url: `${apiKey}/${stream.infoHash}/${encodedFileName}/${stream.fileIdx}`, cached: isCached }; return mochStreams; @@ -137,7 +136,8 @@ async function _retryCreateTorrent(OC, infoHash, cachedEntryInfo, fileIndex) { async function _unrestrictLink(OC, infoHash, torrent, cachedEntryInfo, fileIndex) { const targetFileName = decodeURIComponent(cachedEntryInfo); const files = await _getFileUrls(OC, torrent) - const targetFile = files.find(file => sameFilename(targetFileName, file.split('/').pop())) + const targetFile = files.find(file => file.includes(`/${torrent.requestId}/${fileIndex}/`)) + || files.find(file => sameFilename(targetFileName, file.split('/').pop())) || files.find(file => isVideo(file)) || files.pop();