diff --git a/libs/caper/__init__.py b/libs/caper/__init__.py index 2509c11..9637c06 100644 --- a/libs/caper/__init__.py +++ b/libs/caper/__init__.py @@ -19,7 +19,7 @@ from caper.parsers.anime import AnimeParser from caper.parsers.scene import SceneParser -__version_info__ = ('0', '2', '5') +__version_info__ = ('0', '2', '6') __version_branch__ = 'master' __version__ = "%s%s" % ( diff --git a/libs/caper/constraint.py b/libs/caper/constraint.py index d8f5280..96f45c3 100644 --- a/libs/caper/constraint.py +++ b/libs/caper/constraint.py @@ -53,11 +53,8 @@ class CaptureConstraint(object): elif hasattr(fragment, name): match = self.capture_group.parser.matcher.value_match(getattr(fragment, name), arg, single=True) return 1.0, match is not None - - if not hasattr(fragment, name): - raise ValueError("Unable to find fragment with name '%s'" % name) else: - raise ValueError("Unexpected argument type") + raise ValueError("Unable to find attribute with name '%s'" % name) def execute(self, fragment): results = [] diff --git a/libs/caper/parsers/scene.py b/libs/caper/parsers/scene.py index 764748d..b96967b 100644 --- a/libs/caper/parsers/scene.py +++ b/libs/caper/parsers/scene.py @@ -22,6 +22,12 @@ PATTERN_GROUPS = [ (1.0, [ # S01E01-E02 ('^S(?P\d+)E(?P\d+)$', '^E(?P\d+)$'), + # S03 E01 to E08 + ('^S(?P\d+)$', '^E(?P\d+)$', '^to$', '^E(?P\d+)$'), + + # S01-S03 + ('^S(?P\d+)$', '^S(?P\d+)$'), + # S02E13 r'^S(?P\d+)E(?P\d+)$', # S01 E13 @@ -72,25 +78,62 @@ PATTERN_GROUPS = [ '1080p' ]), + # + # Source + # + (r'(?P%s)', [ + 'DVDRiP', + # HDTV 'HDTV', 'PDTV', 'DSR', - 'DVDRiP', - 'WEBDL' + # WEB + 'WEBRip', + 'WEBDL', + # BluRay + 'BluRay', + 'B(D|R)Rip', + # DVD + 'DVDR', + 'DVD9', + 'DVD5' ]), - # For 'WEB-DL', 'WEB DL', etc... - ('(?PWEB)', '(?PDL)'), + # For multi-fragment 'WEB-DL', 'WEB-Rip', etc... matches + ('(?PWEB)', '(?PDL|Rip)'), + + # + # Codec + # (r'(?P%s)', [ 'x264', 'XViD', - 'H264' + 'H264', + 'AVC' ]), - # For 'H 264' tags + # For multi-fragment 'H 264' tags ('(?PH)', '(?P264)'), + ]), + + ('dvd', [ + r'D(ISC)?(?P\d+)', + + r'R(?P[0-8])', + + (r'(?P%s)', [ + 'PAL', + 'NTSC' + ]), + ]), + + ('audio', [ + (r'(?P%s)', [ + 'AC3', + 'TrueHD' + ]), (r'(?P%s)', [ 'GERMAN', @@ -100,6 +143,10 @@ PATTERN_GROUPS = [ 'DANiSH', 'iTALiAN' ]), + ]), + + ('scene', [ + r'(?PPROPER|REAL)', ]) ] @@ -123,11 +170,17 @@ class SceneParser(Parser): self.capture_fragment('show_name', single=False)\ .until(fragment__re='identifier')\ - .until(fragment__re='video')\ + .until(fragment__re='video') \ + .until(fragment__re='dvd') \ + .until(fragment__re='audio') \ + .until(fragment__re='scene') \ .execute() self.capture_fragment('identifier', regex='identifier', single=False)\ - .capture_fragment('video', regex='video', single=False)\ + .capture_fragment('video', regex='video', single=False) \ + .capture_fragment('dvd', regex='dvd', single=False) \ + .capture_fragment('audio', regex='audio', single=False) \ + .capture_fragment('scene', regex='scene', single=False) \ .until(left_sep__eq='-', right__eq=None)\ .execute() diff --git a/libs/caper/result.py b/libs/caper/result.py index 4d57f89..24037cd 100644 --- a/libs/caper/result.py +++ b/libs/caper/result.py @@ -95,7 +95,7 @@ class CaperResult(object): self.chains.append(chain) for chain in self.chains: - chain.weights.append(chain.num_matched / float(max_matched or chain.num_matched)) + chain.weights.append(chain.num_matched / float(max_matched or chain.num_matched or 1)) chain.finish() self.chains.sort(key=lambda chain: chain.weight, reverse=True)