Added command to change season number

This commit is contained in:
walcutt 2025-06-25 13:38:58 -04:00
parent 70002b2ba7
commit 037f7403fb
2 changed files with 29 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import { addSubtitleTrack } from "./commands/add-subs.js";
import { changeSeason } from "./commands/change-season.js";
import { encodeX265 } from "./commands/encode-265.js";
import { extractToEpisodeNumber } from "./commands/extract-to-se.js";
import { finalizeFileNames } from "./commands/finalize-filenames.js";
@ -24,6 +25,12 @@ export const CommandConfig = [
params: [],
func: extractToEpisodeNumber,
},
{
name: 'Change Season Number',
commands: ['-se', '-season', '-change-season-number'],
params: ['SeasonNumber'],
func: changeSeason,
},
{
name: 'Finalize File Names',
commands: ['-o', '-output-as', '-rename-series'],

View File

@ -0,0 +1,22 @@
import fs from "fs";
import { getFilenameObject } from "../parsing/parse-filename.js";
const seasonEpisodePattern = /[Ss][0-9]+[Ee]([0-9]+)/;
export function changeSeason(inputDir, inputFile, outputDir, { SeasonNumber }) {
const match = inputFile.match(seasonEpisodePattern);
if(match) {
const episodeNumber = match[1];
const newSeasonEpisode = `S${SeasonNumber}E${episodeNumber}`;
const filenameObject = getFilenameObject(inputFile);
const toWrite = `${outputDir}${newSeasonEpisode}${filenameObject.extension}`;
fs.cpSync(`${inputDir}${inputFile}`, `${toWrite}`);
return true;
}
return false;
}