diff --git a/src/command-config.js b/src/command-config.js index 15bf65d..7ff9716 100644 --- a/src/command-config.js +++ b/src/command-config.js @@ -1,6 +1,7 @@ import { addSubtitleTrack } from "./commands/add-subs.js"; import { extractToEpisodeNumber } from "./commands/extract-to-se.js"; import { finalizeFileNames } from "./commands/finalize-filenames.js"; +import { convertToMkv } from "./commands/to-mkv.js"; export const CommandConfig = [ { @@ -20,5 +21,11 @@ export const CommandConfig = [ commands: ['-s'], params: ['SubtitleDirectory'], func: addSubtitleTrack, + }, + { + name: 'Repackage to Mkv', + commands: ['-m'], + params: [], + func: convertToMkv, } ]; \ No newline at end of file diff --git a/src/commands/to-mkv.js b/src/commands/to-mkv.js new file mode 100644 index 0000000..988c3f2 --- /dev/null +++ b/src/commands/to-mkv.js @@ -0,0 +1,23 @@ +import { getFilenameObject } from "../parsing/parse-filename.js"; +import { exec } from "../shell/exec.js"; + +const AcceptedMovieExtensions = [ + '.mp4', + '.avi', + '.mkv', + '.mov', + '.webm' +]; + +export async function convertToMkv(inputDir, inputFile, outputDir, options) { + const filenameObject = getFilenameObject(inputFile); + if(!AcceptedMovieExtensions.includes(filenameObject.extension)) { + return false; + } + + await exec( + `ffmpeg -i ${inputDir}${inputFile} -map 0 -c copy ${outputDir}${filenameObject.prefix}.mkv` + ); + + return true; +} \ No newline at end of file