Skip to content

Commit

Permalink
fix(regex): movie and tv (pack and episode) regex
Browse files Browse the repository at this point in the history
The following are changes made to improve matching for TV (season pack and episode) as well as movies.

All Regex's
* Replaced literal space (' ') in expressions with \s

MOVIE_REGEX
* Added support for '_' in release name.

SEASON_REGEX
* Added support for '_' in release naming.
* Capture multiple variations (including poorly named) of multiple season packs properly.
* Fixed matching incorrectly when season has more than one digit

EP_REGEX
* Added more variations on multi-episode capturing

**fix/update(regex): change title capture to lazy**

* Modify <title> capture group to match lazily, reducing the number of step proportional to the length of the release name.

**fix(regex): corrected <seasonmax> matching**

* <seasonmax> previously required formatting to be S## while not all releases contain the preceding S in multi-season packs.
* Removed the '_' from separator between seasons in multi season packs.

If you run some test cases and find any outliers or mismatching, please comment and note what release naming you used to demonstrate.
  • Loading branch information
zakkarry committed Sep 13, 2023
1 parent cbf18b6 commit b9f8402
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const PROGRAM_NAME = packageDotJson.name;
export const PROGRAM_VERSION = packageDotJson.version;
export const USER_AGENT = `CrossSeed/${PROGRAM_VERSION}`;

export const EP_REGEX = /^(?<title>.+)[. ](?<season>S\d+)(?<episode>E\d+)/i;
export const EP_REGEX = /^(?<title>.+?)[\s._](?<season>S\d+)?[_.\s]?(?<episode>E\d+(?:[-\s]?E?\d+)?)/i;
export const SEASON_REGEX =
/^(?<title>.+)[. ](?<season>S\d+)(?:\s?-\s?(?<seasonmax>S?\d+))?(?!E\d+)/i;
/^(?<title>.+?)[_.\s](?<season>S\d+)(?:[.\-\s]*?(?<seasonmax>S?\d+))?(?=[_.\s](?!E\d+))/i;
export const MOVIE_REGEX =
/^(?<title>.+)[. ][[(]?(?<year>\d{4})[)\]]?(?![pi])/i;
/^(?<title>.+?)[._\s][[(]?(?<year>\d{4})[)\]]?(?![pi])/i;

export const VIDEO_EXTENSIONS = [".mkv", ".mp4", ".avi"];

Expand Down

0 comments on commit b9f8402

Please sign in to comment.