Feature parity with scripts
This commit is contained in:
parent
44fdad9863
commit
e195ba7f68
@ -1,31 +1,73 @@
|
||||
import { addSubtitleTrack } from "./commands/add-subs.js";
|
||||
import { encodeX265 } from "./commands/encode-265.js";
|
||||
import { extractToEpisodeNumber } from "./commands/extract-to-se.js";
|
||||
import { finalizeFileNames } from "./commands/finalize-filenames.js";
|
||||
import { preferAudio } from "./commands/prefer-audio.js";
|
||||
import { preferSubtitles } from "./commands/prefer-subs.js";
|
||||
import { removeSubtitles } from "./commands/remove-subs.js";
|
||||
import { saveSubtitlesToFile } from "./commands/save-subtitles-to-file.js";
|
||||
import { convertToMkv } from "./commands/to-mkv.js";
|
||||
import { convertToMp4 } from "./commands/to-mp4.js";
|
||||
|
||||
export const CommandConfig = [
|
||||
{
|
||||
name: 'Extract To Episode Number',
|
||||
commands: ['-x'],
|
||||
commands: ['-x', '-extract', '-extract-episode-number'],
|
||||
params: [],
|
||||
func: extractToEpisodeNumber,
|
||||
},
|
||||
{
|
||||
name: 'Finalize File Names',
|
||||
commands: ['-o'],
|
||||
commands: ['-o', '-output-as', '-rename'],
|
||||
params: ['ShowName'],
|
||||
func: finalizeFileNames,
|
||||
},
|
||||
{
|
||||
name: 'Add Subtitle Track',
|
||||
commands: ['-s'],
|
||||
commands: ['-s', '-subtitle', '-add-subtitles'],
|
||||
params: ['SubtitleDirectory'],
|
||||
func: addSubtitleTrack,
|
||||
},
|
||||
{
|
||||
name: 'Repackage to Mkv',
|
||||
commands: ['-m'],
|
||||
commands: ['-mkv', '-to-mkv'],
|
||||
params: [],
|
||||
func: convertToMkv,
|
||||
},
|
||||
{
|
||||
name: 'Repackage to Mp4',
|
||||
commands: ['-mp4', '-to-mp4'],
|
||||
params: [],
|
||||
func: convertToMp4,
|
||||
},
|
||||
{
|
||||
name: 'Re-encode as x265',
|
||||
commands: ['-e', '-encode-x265'],
|
||||
params: ['Crf', 'Preset'],
|
||||
func: encodeX265,
|
||||
},
|
||||
{
|
||||
name: 'Change preferred audio',
|
||||
commands: ['-pa', '-prefer-audio'],
|
||||
params: ['TrackNumber'],
|
||||
func: preferAudio,
|
||||
},
|
||||
{
|
||||
name: 'Change preferred subtitle track',
|
||||
commands: ['-ps', '-prefer-subtitles'],
|
||||
params: ['TrackNumber'],
|
||||
func: preferSubtitles,
|
||||
},
|
||||
{
|
||||
name: 'Generate subtitle files',
|
||||
commands: ['-save-subs'],
|
||||
params: ['TrackNumber', 'FileType'],
|
||||
func: saveSubtitlesToFile,
|
||||
},
|
||||
{
|
||||
name: 'Remove subtitles',
|
||||
commands: ['-rs', '-remove-subtitles'],
|
||||
params: [],
|
||||
func: removeSubtitles,
|
||||
}
|
||||
];
|
||||
15
src/commands/encode-265.js
Normal file
15
src/commands/encode-265.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { getFilenameObject } from "../parsing/parse-filename.js";
|
||||
import { exec } from "../shell/exec.js";
|
||||
|
||||
export async function encodeX265(inputDir, inputFile, outputDir, { Crf, Preset }) {
|
||||
const filenameObject = getFilenameObject(inputFile);
|
||||
if(filenameObject.extension !== '.mkv') {
|
||||
return false;
|
||||
}
|
||||
|
||||
await exec(
|
||||
`ffmpeg -i ${inputDir}${inputFile} -map 0 -c copy -c:v libx265 -crf ${Crf} -preset ${Preset} ${outputDir}${inputFile}`
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
15
src/commands/prefer-audio.js
Normal file
15
src/commands/prefer-audio.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { getFilenameObject } from "../parsing/parse-filename.js";
|
||||
import { exec } from "../shell/exec.js";
|
||||
|
||||
export async function preferAudio(inputDir, inputFile, outputDir, { TrackNumber }) {
|
||||
const filenameObject = getFilenameObject(inputFile);
|
||||
if(filenameObject.extension !== '.mkv') {
|
||||
return false;
|
||||
}
|
||||
|
||||
await exec(
|
||||
`ffmpeg -i ${inputDir}${inputFile} -map 0 -c copy -disposition:a 0 -disposition:a:${TrackNumber} default ${outputDir}${inputFile}`
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
15
src/commands/prefer-subs.js
Normal file
15
src/commands/prefer-subs.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { getFilenameObject } from "../parsing/parse-filename.js";
|
||||
import { exec } from "../shell/exec.js";
|
||||
|
||||
export async function preferSubtitles(inputDir, inputFile, outputDir, { TrackNumber }) {
|
||||
const filenameObject = getFilenameObject(inputFile);
|
||||
if(filenameObject.extension !== '.mkv') {
|
||||
return false;
|
||||
}
|
||||
|
||||
await exec(
|
||||
`ffmpeg -i ${inputDir}${inputFile} -map 0 -c copy -disposition:s 0 -disposition:s:${TrackNumber} default ${outputDir}${inputFile}`
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
9
src/commands/remove-subs.js
Normal file
9
src/commands/remove-subs.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { exec } from "../shell/exec.js";
|
||||
|
||||
export async function removeSubtitles(inputDir, inputFile, outputDir, options) {
|
||||
await exec(
|
||||
`ffmpeg -i ${inputDir}${inputFile} -map 0:v -map 0:a -c copy ${outputDir}${inputFile}`
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
12
src/commands/save-subtitles-to-file.js
Normal file
12
src/commands/save-subtitles-to-file.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { getFilenameObject } from "../parsing/parse-filename.js";
|
||||
import { exec } from "../shell/exec.js";
|
||||
|
||||
export async function saveSubtitlesToFile(inputDir, inputFile, outputDir, { TrackNumber, FileType }) {
|
||||
const filenameObject = getFilenameObject(inputFile);
|
||||
|
||||
await exec(
|
||||
`ffmpeg -i ${inputDir}${inputFile} -map 0:s:${TrackNumber} ${outputDir}${filenameObject.prefix}.${FileType}`
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1,13 +1,6 @@
|
||||
import { getFilenameObject } from "../parsing/parse-filename.js";
|
||||
import { exec } from "../shell/exec.js";
|
||||
|
||||
const AcceptedMovieExtensions = [
|
||||
'.mp4',
|
||||
'.avi',
|
||||
'.mkv',
|
||||
'.mov',
|
||||
'.webm'
|
||||
];
|
||||
import { AcceptedMovieExtensions } from "../constants/movie-extensions.js";
|
||||
|
||||
export async function convertToMkv(inputDir, inputFile, outputDir, options) {
|
||||
const filenameObject = getFilenameObject(inputFile);
|
||||
|
||||
16
src/commands/to-mp4.js
Normal file
16
src/commands/to-mp4.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { getFilenameObject } from "../parsing/parse-filename.js";
|
||||
import { exec } from "../shell/exec.js";
|
||||
import { AcceptedMovieExtensions } from "../constants/movie-extensions.js";
|
||||
|
||||
export async function convertToMp4(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}.mp4`
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
7
src/constants/movie-extensions.js
Normal file
7
src/constants/movie-extensions.js
Normal file
@ -0,0 +1,7 @@
|
||||
export const AcceptedMovieExtensions = [
|
||||
'.mp4',
|
||||
'.avi',
|
||||
'.mkv',
|
||||
'.mov',
|
||||
'.webm'
|
||||
];
|
||||
Loading…
x
Reference in New Issue
Block a user