fix episode title parser grabbing release group when title is missing
Build and Push Docker Image / build (push) Successful in 2m30s
Build and Push Docker Image / build (push) Successful in 2m30s
Episodes without a title in the filename (e.g. "Lost - S02E21 - [DSNP WEBDL-1080p]") had their name set to "[DSNP WEBDL-1080p]" because the non-greedy (.+?) still matched into the bracket. Changed capture group to ([^\[]+?) so it refuses to match "[", falling back to the SxxExx identifier instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,20 @@ describe("parsePath", () => {
|
||||
expect(parsePath("/other/Hot Fuzz (2007)/Hot Fuzz (2007) [imdbid-tt0425112].mkv", MOVIES, TV)).toBeNull();
|
||||
});
|
||||
|
||||
test("episode without episode title falls back to SxxExx", () => {
|
||||
const result = parsePath(
|
||||
"/tv/Lost (2004)/Season 02/Lost (2004) - S02E21 - [DSNP WEBDL-1080p][EAC3 5.1][h264]-FLUX.mkv",
|
||||
MOVIES,
|
||||
TV,
|
||||
);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.type).toBe("Episode");
|
||||
expect(result!.seriesName).toBe("Lost");
|
||||
expect(result!.seasonNumber).toBe(2);
|
||||
expect(result!.episodeNumber).toBe(21);
|
||||
expect(result!.name).toBe("S02E21");
|
||||
});
|
||||
|
||||
test("movie without provider ids (bare folder)", () => {
|
||||
const result = parsePath(
|
||||
"/movies/No Country for Old Men (2007)/No Country for Old Men (2007) - [Bluray-1080p].mkv",
|
||||
|
||||
@@ -100,8 +100,9 @@ function parseEpisode(filePath: string, tvPrefix: string, fileName: string, ext:
|
||||
|
||||
// Episode title: everything after "- S01E01... -" up to the first "[".
|
||||
// e.g. "Breaking Bad (2008) - S05E03 - Hazard Pay [WEBDL-...]"
|
||||
const epTitleMatch = fileName.match(/S\d{2}E\d{2}(?:-E\d{2})?\s*-\s*(.+?)(?:\s*\[|$)/i);
|
||||
const episodeTitle = epTitleMatch ? epTitleMatch[1].trim() : fileName;
|
||||
// Some files have no episode title: "Lost (2004) - S02E21 - [DSNP WEBDL-1080p]..."
|
||||
const epTitleMatch = fileName.match(/S\d{2}E\d{2}(?:-E\d{2})?\s*-\s*([^\[]+?)(?:\s*\[|$)/i);
|
||||
const episodeTitle = epTitleMatch ? epTitleMatch[1].trim() || `S${seMatch[1]}E${seMatch[2]}` : `S${seMatch[1]}E${seMatch[2]}`;
|
||||
|
||||
return {
|
||||
type: "Episode",
|
||||
|
||||
Reference in New Issue
Block a user