mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
use custom fn to detect same filename in debrids
This commit is contained in:
@@ -4,7 +4,7 @@ import { Type } from '../lib/types.js';
|
||||
import { isVideo } from '../lib/extension.js';
|
||||
import StaticResponse from './static.js';
|
||||
import { getMagnetLink } from '../lib/magnetHelper.js';
|
||||
import { chunkArray, BadTokenError } from './mochHelper.js';
|
||||
import { chunkArray, BadTokenError, sameFilename } from './mochHelper.js';
|
||||
|
||||
const KEY = 'offcloud';
|
||||
|
||||
@@ -125,10 +125,11 @@ async function _createTorrent(OC, infoHash) {
|
||||
}
|
||||
|
||||
async function _unrestrictLink(OC, infoHash, torrent, cachedEntryInfo, fileIndex) {
|
||||
const targetFileName = decodeURIComponent(cachedEntryInfo);
|
||||
const files = await _getFileUrls(OC, torrent)
|
||||
const targetFile = Number.isInteger(fileIndex)
|
||||
? files.find(file => file.includes(`/${torrent.requestId}/${fileIndex}/`))
|
||||
: files.find(file => isVideo(file));
|
||||
? files.find(file => sameFilename(targetFileName, file.split('/').pop()))
|
||||
: files.find(file => isVideo(file)) || files.pop();
|
||||
|
||||
if (!targetFile) {
|
||||
return Promise.reject(`No Offcloud links found for index ${fileIndex} in: ${JSON.stringify(torrent)}`);
|
||||
|
||||
Reference in New Issue
Block a user