From 75dee9b50bf57d76743b16b2cb7386b611348d33 Mon Sep 17 00:00:00 2001 From: Trim21 Date: Sat, 4 May 2024 00:57:23 +0800 Subject: [PATCH] fix: only generate mediainfo for video file (#741) --- server/routes/api/torrents.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/routes/api/torrents.ts b/server/routes/api/torrents.ts index f71f9076..70a56a50 100644 --- a/server/routes/api/torrents.ts +++ b/server/routes/api/torrents.ts @@ -920,7 +920,17 @@ router.get<{hash: string}>( const mediainfoProcess = childProcess.execFile( 'mediainfo', - torrentContentPaths.map((x) => path.relative(torrentDirectory, x)), + torrentContentPaths + .filter((x) => { + const fn = x.toLowerCase(); + for (const ext of ['.mp4', '.mkv', '.ts', '.avi', '.rmvb', '.dat', '.wmv', '.iso']) { + if (fn.endsWith(ext)) { + return true; + } + } + return false; + }) + .map((x) => path.relative(torrentDirectory, x)), {maxBuffer: 1024 * 2000, timeout: 1000 * 10, cwd: torrentDirectory}, (error, stdout) => { if (error) {