From 3c885a0c21ea13fb670f3d27bc1728a6bd50acc8 Mon Sep 17 00:00:00 2001 From: walcutt Date: Tue, 24 Jun 2025 14:30:43 -0400 Subject: [PATCH] Catch regex match issue --- src/commands/extract-to-se.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/commands/extract-to-se.js b/src/commands/extract-to-se.js index 0f5808e..bf2af73 100644 --- a/src/commands/extract-to-se.js +++ b/src/commands/extract-to-se.js @@ -4,32 +4,32 @@ const acceptedPatternMappings = [ { name: 'Full match', pattern: /([Ss][0-9]+[Ee][0-9]+)/, - mapper: (matches) => `${matches[0]}`, + mapper: (matches) => `${matches[1]}`, }, { name: 'Space separated single number', pattern: / ([0-9][0-9]+) /, - mapper: (matches) => `S01E${matches[0]}`, + mapper: (matches) => `S01E${matches[1]}`, }, { name: 'End of filename number, leading space', pattern: / ([0-9][0-9]+)\./, - mapper: (matches) => `S01E${matches[0]}`, + mapper: (matches) => `S01E${matches[1]}`, }, { name: 'Underscore separated number', pattern: /_([0-9][0-9]+)_/, - mapper: (matches) => `S01E${matches[0]}`, + mapper: (matches) => `S01E${matches[1]}`, }, { name: 'End of filename number, leading underscore', pattern: /_([0-9][0-9]+)\./, - mapper: (matches) => `S01E${matches[0]}`, + mapper: (matches) => `S01E${matches[1]}`, }, { name: 'Any number >= 2 characters', pattern: /([0-9][0-9]+)/, - mapper: (matches) => `S01E${matches[0]}`, + mapper: (matches) => `S01E${matches[1]}`, }, ]; @@ -43,7 +43,7 @@ export async function extractToEpisodeNumber(inputDir, inputFile, outputDir, opt const extensionMatches = inputFile.match(extensionPattern); - const extension = extensionMatches ? extensionMatches[0] : ''; + const extension = extensionMatches ? extensionMatches[1] : ''; const toWrite = `${outputDir}${outputFileName}${extension}`;