chore: improve mediainfo no video file error (#742)

This commit is contained in:
Trim21
2024-05-04 01:08:33 +08:00
committed by GitHub
parent 75dee9b50b
commit 39e0e3eb92

View File

@@ -918,10 +918,7 @@ router.get<{hash: string}>(
return res.status(404).json({code, message});
}
const mediainfoProcess = childProcess.execFile(
'mediainfo',
torrentContentPaths
.filter((x) => {
const args = torrentContentPaths.filter((x) => {
const fn = x.toLowerCase();
for (const ext of ['.mp4', '.mkv', '.ts', '.avi', '.rmvb', '.dat', '.wmv', '.iso']) {
if (fn.endsWith(ext)) {
@@ -929,8 +926,18 @@ router.get<{hash: string}>(
}
}
return false;
})
.map((x) => path.relative(torrentDirectory, x)),
});
if (args.length < 1) {
return res.status(200).json({
output:
'no video file found.\nIf this is a error, please create a issue at https://github.com/jesec/flood/issues',
});
}
const mediainfoProcess = childProcess.execFile(
'mediainfo',
args.map((x) => path.relative(torrentDirectory, x)),
{maxBuffer: 1024 * 2000, timeout: 1000 * 10, cwd: torrentDirectory},
(error, stdout) => {
if (error) {