Skip to content

Commit

Permalink
fix(regex): title capturing trailing separator (cross-seed#524)
Browse files Browse the repository at this point in the history
## TV REGEX <title> group capturing trailing separator

the regex previously captures separators trailing <title> capture group
needlessly when separated with a space prior to SxxExx/Sxx (" - ") and
will add the non-space separator to the search string. this usually
applies when data searching an arr library/root folder.

this PR fixes this behavior and removes the separators after title from
title's capture group.

- [x] EP_REGEX Test Cases: https://regex101.com/r/fuE0bM/2
- [x] SEASON_REGEX Test Cases: https://regex101.com/r/fuE0bM/1

(also removed unused variable from qbit injection function)
  • Loading branch information
zakkarry authored Oct 16, 2023
1 parent 0cdbb23 commit ef83f90
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/clients/QBittorrent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default class QBittorrent implements TorrentClient {
searchee: Searchee,
path?: string
): Promise<InjectionResult> {
const { duplicateCategories, linkDir, skipRecheck, dataCategory } =
const { duplicateCategories, skipRecheck, dataCategory } =
getRuntimeConfig();
try {
if (await this.isInfoHashInClient(newTorrent.infoHash)) {
Expand Down
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const PROGRAM_VERSION = packageDotJson.version;
export const USER_AGENT = `CrossSeed/${PROGRAM_VERSION}`;

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

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path, { basename, join } from "path";
import path, { basename } from "path";
import {
EP_REGEX,
MOVIE_REGEX,
Expand Down

0 comments on commit ef83f90

Please sign in to comment.