fix: only generate mediainfo for video file (#741)

This commit is contained in:
Trim21
2024-05-04 00:57:23 +08:00
committed by GitHub
parent 875a575833
commit 75dee9b50b

View File

@@ -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) {