From 51e49f984cf22c3945cb63b9b6b51de12a68ac26 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 1 Apr 2024 19:17:52 -0400 Subject: [PATCH] feat(node-sub): only look for mkv for video files --- .../nos/modules/subtitles/syncing/node-syncsub/main.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/main.ts b/devices/nos/modules/subtitles/syncing/node-syncsub/main.ts index 37b83b01..f80e5488 100755 --- a/devices/nos/modules/subtitles/syncing/node-syncsub/main.ts +++ b/devices/nos/modules/subtitles/syncing/node-syncsub/main.ts @@ -37,9 +37,7 @@ function getVideoPath(files: string[]) { const fileName = DIR.split('/').at(-1) ?? ''; const videoFiles = files.filter((f) => - f.includes(fileName) && - !f.endsWith('.nfo') && - !f.endsWith('.srt')); + f.includes(fileName) && f.endsWith('mkv')); if (videoFiles.length === 0) { console.warn('No video files were found'); @@ -156,13 +154,13 @@ async function main() { console.warn(`No subtitle tracks were found for ${lang}`); } else { - // Extract subtitles + // Extract subtitle spawn('ffmpeg', [ '-i', `'${VIDEO}'`, '-map', `"0:${subs[0].index}"`, `'${IN_FILE}'`, ], SPAWN_OPTS); - // Delete subtitles from video + // Delete subtitle from video spawn('mv', [`'${VIDEO}'`, `'${VIDEO}.bak'`], SPAWN_OPTS); spawn('ffmpeg', [ @@ -174,6 +172,7 @@ async function main() { spawn('rm', [`'${VIDEO}.bak'`], SPAWN_OPTS); + // Sync extracted subtitle runSubSync(cmd, async() => { await mv(IN_FILE, OUT_FILE); });