From 0a04fd3948441178c63d661976e2af273aa83676 Mon Sep 17 00:00:00 2001 From: Toilal Date: Sun, 18 Sep 2016 11:47:44 +0200 Subject: [PATCH] Fix Title not properly guessed when 'Complete' appears with 'The' article. Requires new rebulk version (0.7.5) Close #340 --- guessit/rules/properties/episodes.py | 4 ++-- guessit/rules/properties/other.py | 28 +++++++++++++++++++++++----- guessit/test/episodes.yml | 17 ++++++++++++++++- setup.py | 2 +- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/guessit/rules/properties/episodes.py b/guessit/rules/properties/episodes.py index d0f6f72..6432e28 100644 --- a/guessit/rules/properties/episodes.py +++ b/guessit/rules/properties/episodes.py @@ -7,7 +7,7 @@ import copy from collections import defaultdict from rebulk import Rebulk, RemoveMatch, Rule, AppendMatch, RenameMatch -from rebulk.match import Matches, Match +from rebulk.match import Match from rebulk.remodule import re from rebulk.utils import is_iterable @@ -81,7 +81,7 @@ def episodes(): """ Validator for season list. They should be in natural order to be validated. """ - values = Matches(match.children).to_dict(implicit=True) + values = match.children.to_dict(implicit=True) if 'season' in values and is_iterable(values['season']): # Season numbers must be in natural order to be validated. return list(sorted(values['season'])) == values['season'] diff --git a/guessit/rules/properties/other.py b/guessit/rules/properties/other.py index 8ed06a5..1c51eea 100644 --- a/guessit/rules/properties/other.py +++ b/guessit/rules/properties/other.py @@ -10,7 +10,7 @@ from rebulk.remodule import re from rebulk import Rebulk, Rule, RemoveMatch, POST_PROCESS, AppendMatch from ..common import dash from ..common import seps -from ..common.validators import seps_surround +from ..common.validators import seps_surround, compose from ...rules.common.formatters import raw_cleanup from ...reutils import build_or_pattern @@ -35,11 +35,29 @@ def other(): rebulk.string('Fansub', value='Fansub', tags='has-neighbor') rebulk.string('Fastsub', value='Fastsub', tags='has-neighbor') - complete_words = build_or_pattern(["seasons?", "series?"]) + season_words = build_or_pattern(["seasons?", "series?"]) + complete_articles = build_or_pattern(["The"]) - rebulk.regex('(?:' + complete_words + '-)?Complete' + '(?:-' + complete_words + ')?', - value='Complete', tags=['release-group-prefix'], - validator=lambda match: seps_surround(match) and match.raw.lower().strip(seps) != "complete") + def validate_complete(match): + """ + Make sure season word is are defined. + :param match: + :type match: + :return: + :rtype: + """ + children = match.children + if not children.named('completeWordsBefore') and not children.named('completeWordsAfter'): + return False + return True + + rebulk.regex('(?P' + complete_articles + '-)?' + + '(?P' + season_words + '-)?' + + 'Complete' + '(?P-' + season_words + ')?', + private_names=['completeArticle', 'completeWordsBefore', 'completeWordsAfter'], + value={'other': 'Complete'}, + tags=['release-group-prefix'], + validator={'__parent__': compose(seps_surround, validate_complete)}) rebulk.string('R5', 'RC', value='R5') rebulk.regex('Pre-?Air', value='Preair') diff --git a/guessit/test/episodes.yml b/guessit/test/episodes.yml index 05bf279..3347cd5 100644 --- a/guessit/test/episodes.yml +++ b/guessit/test/episodes.yml @@ -2004,4 +2004,19 @@ release_group: AR title: How I Met Your Mother type: movie - video_codec: XviD \ No newline at end of file + video_codec: XviD + +? Show Name The Complete Seasons 1 to 5 720p BluRay x265 HEVC-SUJAIDR[UTR] +: format: BluRay + other: Complete + release_group: SUJAIDR[UTR] + screen_size: 720p + season: + - 1 + - 2 + - 3 + - 4 + - 5 + title: Show Name + type: episode + video_codec: h265 \ No newline at end of file diff --git a/setup.py b/setup.py index ae7118d..53cc322 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: with io.open(os.path.join(here, 'HISTORY.rst'), encoding='utf-8') as f: history = f.read() -install_requires = ['rebulk>=0.7.4', 'babelfish>=0.5.5', 'python-dateutil'] +install_requires = ['rebulk>=0.7.5', 'babelfish>=0.5.5', 'python-dateutil'] if sys.version_info < (2, 7): install_requires.extend(['argparse', 'ordereddict']) setup_requires = ['pytest-runner']