use custom fn to detect same filename in debrids

This commit is contained in:
TheBeastLT
2023-12-16 19:04:53 +02:00
parent 2c4da0679f
commit afa1458144
5 changed files with 13 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ import { Type } from '../lib/types.js';
import { isVideo, isArchive } from '../lib/extension.js';
import StaticResponse from './static.js';
import { getMagnetLink } from '../lib/magnetHelper.js';
import { BadTokenError, AccessDeniedError } from './mochHelper.js';
import { BadTokenError, AccessDeniedError, sameFilename } from './mochHelper.js';
const KEY = 'alldebrid';
const AGENT = 'torrentio';
@@ -144,7 +144,7 @@ async function _unrestrictLink(AD, torrent, encodedFileName, fileIndex) {
const targetFileName = decodeURIComponent(encodedFileName);
const videos = torrent.links.filter(link => isVideo(link.filename));
const targetVideo = Number.isInteger(fileIndex)
? videos.find(video => targetFileName.includes(video.filename))
? videos.find(video => sameFilename(targetFileName, video.filename))
: videos.sort((a, b) => b.size - a.size)[0];
if (!targetVideo && torrent.links.every(link => isArchive(link.filename))) {