Skip to content

Commit

Permalink
Fix invalid guess when crc32 contains a date.
Browse files Browse the repository at this point in the history
It also fix possible crashed in guess_bonus_feature transformer.

Close #194
  • Loading branch information
Toilal committed Apr 4, 2015
1 parent 324901c commit 1941e49
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions guessit/date.py
Expand Up @@ -31,8 +31,8 @@
_dsep_bis = r'[-/ \.x]'

date_regexps = [
re.compile('[^\d](\d{8})[^\d]', re.IGNORECASE),
re.compile('[^\d](\d{6})[^\d]', re.IGNORECASE),
re.compile('%s(\d{8})%s' % (_dsep, _dsep), re.IGNORECASE),
re.compile('%s(\d{6})%s' % (_dsep, _dsep), re.IGNORECASE),
re.compile('[^\d](\d{2})%s(\d{1,2})%s(\d{1,2})[^\d]' % (_dsep, _dsep), re.IGNORECASE),
re.compile('[^\d](\d{1,2})%s(\d{1,2})%s(\d{2})[^\d]' % (_dsep, _dsep), re.IGNORECASE),
re.compile('[^\d](\d{4})%s(\d{1,2})%s(\d{1,2})[^\d]' % (_dsep_bis, _dsep), re.IGNORECASE),
Expand Down
2 changes: 1 addition & 1 deletion guessit/language.py
Expand Up @@ -169,7 +169,7 @@ def reverse(self, name):
'no', 'non', 'war', 'min', 'new', 'car', 'day', 'bad', 'bat', 'fan',
'fry', 'cop', 'zen', 'gay', 'fat', 'one', 'cherokee', 'got', 'an', 'as',
'cat', 'her', 'be', 'hat', 'sun', 'may', 'my', 'mr', 'rum', 'pi', 'bb', 'bt',
'tv', 'aw', 'by', 'md', 'mp', 'cd', 'lt', 'gt', 'in', 'ad', 'ice', 'ay',
'tv', 'aw', 'by', 'md', 'mp', 'cd', 'lt', 'gt', 'in', 'ad', 'ice', 'ay', 'at',
# french words
'bas', 'de', 'le', 'son', 'ne', 'ca', 'ce', 'et', 'que',
'mal', 'est', 'vol', 'or', 'mon', 'se', 'je', 'tu', 'me',
Expand Down
19 changes: 10 additions & 9 deletions guessit/matcher.py
Expand Up @@ -171,15 +171,16 @@ def build_guess(node, name, value=None, confidence=1.0):

clean_value = node.clean_value

for i in range(0, len(node.value)):
if clean_value[0] == node.value[i]:
break
left_offset += 1

for i in reversed(range(0, len(node.value))):
if clean_value[-1] == node.value[i]:
break
right_offset += 1
if clean_value:
for i in range(0, len(node.value)):
if clean_value[0] == node.value[i]:
break
left_offset += 1

for i in reversed(range(0, len(node.value))):
if clean_value[-1] == node.value[i]:
break
right_offset += 1

guess.metadata().span = (node.span[0] - node.offset + left_offset, node.span[1] - node.offset - right_offset)
return guess
Expand Down
7 changes: 7 additions & 0 deletions guessit/test/autodetect.yaml
Expand Up @@ -498,3 +498,10 @@
episodeNumber: 82
videoCodec: h264

? "[Figmentos] Monster 34 - At the End of Darkness [781219F1].mkv"
: type: episode
releaseGroup: Figmentos
series: Monster
episodeNumber: 34
title: At the End of Darkness
crc32: 781219F1
6 changes: 4 additions & 2 deletions guessit/transfo/guess_bonus_features.py
Expand Up @@ -55,10 +55,12 @@ def same_group(g1, g2):
if 'filmNumber' in node.guess]
if film_number:
film_series = previous_group(film_number[0])
found_property(film_series, 'filmSeries', confidence=0.9)
if film_series:
found_property(film_series, 'filmSeries', confidence=0.9)

title = next_group(film_number[0])
found_property(title, 'title', confidence=0.9)
if title:
found_property(title, 'title', confidence=0.9)

season = [node for node in mtree.leaves() if 'season' in node.guess]
if season and 'bonusNumber' in mtree.info:
Expand Down

0 comments on commit 1941e49

Please sign in to comment.