Skip to content

Commit

Permalink
chore: improve mediainfo no video file error (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored May 3, 2024
1 parent 75dee9b commit 39e0e3e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions server/routes/api/torrents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,19 +918,26 @@ router.get<{hash: string}>(
return res.status(404).json({code, message});
}

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)) {
return true;
}
}
return false;
});

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',
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)),
args.map((x) => path.relative(torrentDirectory, x)),
{maxBuffer: 1024 * 2000, timeout: 1000 * 10, cwd: torrentDirectory},
(error, stdout) => {
if (error) {
Expand Down

0 comments on commit 39e0e3e

Please sign in to comment.