feat(node-sub): only look for mkv for video files
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-04-01 19:17:52 -04:00
parent 1c214aaadd
commit 51e49f984c

View file

@ -37,9 +37,7 @@ function getVideoPath(files: string[]) {
const fileName = DIR.split('/').at(-1) ?? ''; const fileName = DIR.split('/').at(-1) ?? '';
const videoFiles = files.filter((f) => const videoFiles = files.filter((f) =>
f.includes(fileName) && f.includes(fileName) && f.endsWith('mkv'));
!f.endsWith('.nfo') &&
!f.endsWith('.srt'));
if (videoFiles.length === 0) { if (videoFiles.length === 0) {
console.warn('No video files were found'); console.warn('No video files were found');
@ -156,13 +154,13 @@ async function main() {
console.warn(`No subtitle tracks were found for ${lang}`); console.warn(`No subtitle tracks were found for ${lang}`);
} }
else { else {
// Extract subtitles // Extract subtitle
spawn('ffmpeg', [ spawn('ffmpeg', [
'-i', `'${VIDEO}'`, '-i', `'${VIDEO}'`,
'-map', `"0:${subs[0].index}"`, `'${IN_FILE}'`, '-map', `"0:${subs[0].index}"`, `'${IN_FILE}'`,
], SPAWN_OPTS); ], SPAWN_OPTS);
// Delete subtitles from video // Delete subtitle from video
spawn('mv', [`'${VIDEO}'`, `'${VIDEO}.bak'`], SPAWN_OPTS); spawn('mv', [`'${VIDEO}'`, `'${VIDEO}.bak'`], SPAWN_OPTS);
spawn('ffmpeg', [ spawn('ffmpeg', [
@ -174,6 +172,7 @@ async function main() {
spawn('rm', [`'${VIDEO}.bak'`], SPAWN_OPTS); spawn('rm', [`'${VIDEO}.bak'`], SPAWN_OPTS);
// Sync extracted subtitle
runSubSync(cmd, async() => { runSubSync(cmd, async() => {
await mv(IN_FILE, OUT_FILE); await mv(IN_FILE, OUT_FILE);
}); });