Updated Caper to v0.2.4

This commit is contained in:
Dean Gardiner
2013-12-06 00:49:33 +13:00
parent 717111f5d2
commit aa394f59ae
5 changed files with 23 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ from caper.parsers.anime import AnimeParser
from caper.parsers.scene import SceneParser
__version_info__ = ('0', '2', '3')
__version_info__ = ('0', '2', '4')
__version_branch__ = 'master'
__version__ = "%s%s" % (

View File

@@ -51,6 +51,18 @@ def clean_dict(target, remove=None):
return target
def update_dict(a, b):
for key, value in b.items():
if key not in a:
a[key] = value
elif isinstance(a[key], dict) and isinstance(value, dict):
update_dict(a[key], value)
elif isinstance(a[key], list):
a[key].append(value)
else:
a[key] = [a[key], value]
def xrange_six(start, stop=None, step=None):
if stop is not None and step is not None:
if PY3:

View File

@@ -14,13 +14,16 @@
import re
from logr import Logr
from caper.helpers import is_list_type
from caper.helpers import is_list_type, update_dict
class FragmentMatcher(object):
def __init__(self, pattern_groups):
self.regex = {}
self.construct_patterns(pattern_groups)
def construct_patterns(self, pattern_groups):
for group_name, patterns in pattern_groups:
if group_name not in self.regex:
self.regex[group_name] = []
@@ -120,7 +123,7 @@ class FragmentMatcher(object):
match = fragment_pattern.match(cur_fragment.value)
if match:
result.update(match.groupdict())
update_dict(result, match.groupdict())
else:
success = False
break

View File

@@ -77,9 +77,12 @@ PATTERN_GROUPS = [
'PDTV',
'DSR',
'DVDRiP',
'WEBDL' # TODO support 'WEB.DL' tag
'WEBDL'
]),
# For 'WEB-DL', 'WEB DL', etc...
('(?P<source>WEB)', '(?P<source>DL)'),
(r'(?P<codec>%s)', [
'x264',
'XViD'

View File

@@ -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))
chain.weights.append(chain.num_matched / float(max_matched or chain.num_matched))
chain.finish()
self.chains.sort(key=lambda chain: chain.weight, reverse=True)