Skip to content

Commit

Permalink
Reduce the amount of expected titles created. (#10493)
Browse files Browse the repository at this point in the history
* Reduce the amount of expected titles created.
* When the option `Append (year) to each show title` is enabled.

* The regex for year should include parenthises.

For example:
"(2022)" excluded from expected title.
"2022" included from expected title.
  • Loading branch information
p0psicles authored Apr 12, 2022
1 parent 589857e commit 9fe760e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions medusa/name_parser/guessit_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'gb',
]

series_re = re.compile(r'^(?P<series>.*?)(?: \(?(?:(?P<year>\d{4})|(?P<country>[A-Z]{2}))\)?)?$')
series_re = re.compile(r'^(?P<series>.*?)(?: ?(?:(?P<year>\(\d{4}\))|(?P<country>[A-Z]{2}))?)?$')


def guessit(name, options=None):
Expand Down Expand Up @@ -113,9 +113,11 @@ def get_expected_titles(show_list):
if not match:
continue

if not any(char.isdigit() or char == '-' for char in exception):
if not any(char.isdigit() or char == '-' for char in match.group(1)):
continue

# At this point only add titles (without the year ex: 9-1-1 (2018),
# only use `9-1-1`. And only when it has a number or '-' in its title.
expected_titles.append(exception)

return expected_titles
Expand Down
7 changes: 4 additions & 3 deletions medusa/post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,10 @@ def _finalize(self, parse_result):
self.is_proper = bool(parse_result.proper_tags)

# if the result is complete set release name
if parse_result.series_name and ((parse_result.season_number is not None and parse_result.episode_numbers) or
parse_result.air_date) and parse_result.release_group:

if parse_result.series_name and (
(parse_result.season_number is not None and parse_result.episode_numbers)
or parse_result.air_date
) and parse_result.release_group:
if not self.release_name:
self.release_name = remove_extension(os.path.basename(parse_result.original_name))

Expand Down

0 comments on commit 9fe760e

Please sign in to comment.