Added command to change season number
This commit is contained in:
parent
70002b2ba7
commit
037f7403fb
@ -1,4 +1,5 @@
|
|||||||
import { addSubtitleTrack } from "./commands/add-subs.js";
|
import { addSubtitleTrack } from "./commands/add-subs.js";
|
||||||
|
import { changeSeason } from "./commands/change-season.js";
|
||||||
import { encodeX265 } from "./commands/encode-265.js";
|
import { encodeX265 } from "./commands/encode-265.js";
|
||||||
import { extractToEpisodeNumber } from "./commands/extract-to-se.js";
|
import { extractToEpisodeNumber } from "./commands/extract-to-se.js";
|
||||||
import { finalizeFileNames } from "./commands/finalize-filenames.js";
|
import { finalizeFileNames } from "./commands/finalize-filenames.js";
|
||||||
@ -24,6 +25,12 @@ export const CommandConfig = [
|
|||||||
params: [],
|
params: [],
|
||||||
func: extractToEpisodeNumber,
|
func: extractToEpisodeNumber,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Change Season Number',
|
||||||
|
commands: ['-se', '-season', '-change-season-number'],
|
||||||
|
params: ['SeasonNumber'],
|
||||||
|
func: changeSeason,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Finalize File Names',
|
name: 'Finalize File Names',
|
||||||
commands: ['-o', '-output-as', '-rename-series'],
|
commands: ['-o', '-output-as', '-rename-series'],
|
||||||
|
|||||||
22
src/commands/change-season.js
Normal file
22
src/commands/change-season.js
Normal 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;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user