Updated Caper to v0.2.6
This commit is contained in:
1 parent
a6b1cc833f
commit
a23c409939
4 files changed
+64
-14
No files matched your search
@@ -19,7 +19,7 @@ from caper.parsers.anime import AnimeParser
|
|||||||
from caper.parsers.scene import SceneParser
|
from caper.parsers.scene import SceneParser
|
||||||
|
|
||||||
|
|
||||||
__version_info__ = ('0', '2', '5')
|
__version_info__ = ('0', '2', '6')
|
||||||
__version_branch__ = 'master'
|
__version_branch__ = 'master'
|
||||||
|
|
||||||
__version__ = "%s%s" % (
|
__version__ = "%s%s" % (
|
||||||
|
|||||||
@@ -53,11 +53,8 @@ class CaptureConstraint(object):
|
|||||||
elif hasattr(fragment, name):
|
elif hasattr(fragment, name):
|
||||||
match = self.capture_group.parser.matcher.value_match(getattr(fragment, name), arg, single=True)
|
match = self.capture_group.parser.matcher.value_match(getattr(fragment, name), arg, single=True)
|
||||||
return 1.0, match is not None
|
return 1.0, match is not None
|
||||||
|
|
||||||
if not hasattr(fragment, name):
|
|
||||||
raise ValueError("Unable to find fragment with name '%s'" % name)
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unexpected argument type")
|
raise ValueError("Unable to find attribute with name '%s'" % name)
|
||||||
|
|
||||||
def execute(self, fragment):
|
def execute(self, fragment):
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ PATTERN_GROUPS = [
|
|||||||
(1.0, [
|
(1.0, [
|
||||||
# S01E01-E02
|
# S01E01-E02
|
||||||
('^S(?P<season>\d+)E(?P<episode_from>\d+)$', '^E(?P<episode_to>\d+)$'),
|
('^S(?P<season>\d+)E(?P<episode_from>\d+)$', '^E(?P<episode_to>\d+)$'),
|
||||||
|
# S03 E01 to E08
|
||||||
|
('^S(?P<season>\d+)$', '^E(?P<episode_from>\d+)$', '^to$', '^E(?P<episode_to>\d+)$'),
|
||||||
|
|
||||||
|
# S01-S03
|
||||||
|
('^S(?P<season_from>\d+)$', '^S(?P<season_to>\d+)$'),
|
||||||
|
|
||||||
# S02E13
|
# S02E13
|
||||||
r'^S(?P<season>\d+)E(?P<episode>\d+)$',
|
r'^S(?P<season>\d+)E(?P<episode>\d+)$',
|
||||||
# S01 E13
|
# S01 E13
|
||||||
@@ -72,25 +78,62 @@ PATTERN_GROUPS = [
|
|||||||
'1080p'
|
'1080p'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source
|
||||||
|
#
|
||||||
|
|
||||||
(r'(?P<source>%s)', [
|
(r'(?P<source>%s)', [
|
||||||
|
'DVDRiP',
|
||||||
|
# HDTV
|
||||||
'HDTV',
|
'HDTV',
|
||||||
'PDTV',
|
'PDTV',
|
||||||
'DSR',
|
'DSR',
|
||||||
'DVDRiP',
|
# WEB
|
||||||
'WEBDL'
|
'WEBRip',
|
||||||
|
'WEBDL',
|
||||||
|
# BluRay
|
||||||
|
'BluRay',
|
||||||
|
'B(D|R)Rip',
|
||||||
|
# DVD
|
||||||
|
'DVDR',
|
||||||
|
'DVD9',
|
||||||
|
'DVD5'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
# For 'WEB-DL', 'WEB DL', etc...
|
# For multi-fragment 'WEB-DL', 'WEB-Rip', etc... matches
|
||||||
('(?P<source>WEB)', '(?P<source>DL)'),
|
('(?P<source>WEB)', '(?P<source>DL|Rip)'),
|
||||||
|
|
||||||
|
#
|
||||||
|
# Codec
|
||||||
|
#
|
||||||
|
|
||||||
(r'(?P<codec>%s)', [
|
(r'(?P<codec>%s)', [
|
||||||
'x264',
|
'x264',
|
||||||
'XViD',
|
'XViD',
|
||||||
'H264'
|
'H264',
|
||||||
|
'AVC'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
# For 'H 264' tags
|
# For multi-fragment 'H 264' tags
|
||||||
('(?P<codec>H)', '(?P<codec>264)'),
|
('(?P<codec>H)', '(?P<codec>264)'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
('dvd', [
|
||||||
|
r'D(ISC)?(?P<disc>\d+)',
|
||||||
|
|
||||||
|
r'R(?P<region>[0-8])',
|
||||||
|
|
||||||
|
(r'(?P<encoding>%s)', [
|
||||||
|
'PAL',
|
||||||
|
'NTSC'
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
('audio', [
|
||||||
|
(r'(?P<codec>%s)', [
|
||||||
|
'AC3',
|
||||||
|
'TrueHD'
|
||||||
|
]),
|
||||||
|
|
||||||
(r'(?P<language>%s)', [
|
(r'(?P<language>%s)', [
|
||||||
'GERMAN',
|
'GERMAN',
|
||||||
@@ -100,6 +143,10 @@ PATTERN_GROUPS = [
|
|||||||
'DANiSH',
|
'DANiSH',
|
||||||
'iTALiAN'
|
'iTALiAN'
|
||||||
]),
|
]),
|
||||||
|
]),
|
||||||
|
|
||||||
|
('scene', [
|
||||||
|
r'(?P<proper>PROPER|REAL)',
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -123,11 +170,17 @@ class SceneParser(Parser):
|
|||||||
|
|
||||||
self.capture_fragment('show_name', single=False)\
|
self.capture_fragment('show_name', single=False)\
|
||||||
.until(fragment__re='identifier')\
|
.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()
|
.execute()
|
||||||
|
|
||||||
self.capture_fragment('identifier', regex='identifier', single=False)\
|
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)\
|
.until(left_sep__eq='-', right__eq=None)\
|
||||||
.execute()
|
.execute()
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class CaperResult(object):
|
|||||||
self.chains.append(chain)
|
self.chains.append(chain)
|
||||||
|
|
||||||
for chain in self.chains:
|
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()
|
chain.finish()
|
||||||
|
|
||||||
self.chains.sort(key=lambda chain: chain.weight, reverse=True)
|
self.chains.sort(key=lambda chain: chain.weight, reverse=True)
|
||||||
|
|||||||
Reference in new issue
Block a user