Skip to content

Commit

Permalink
feat(other): add Repack and ReRip followed by a digit support (#653)
Browse files Browse the repository at this point in the history
The digit following those tags now as the base value for `proper_count` property.

Close #653
  • Loading branch information
Toilal committed Feb 8, 2021
1 parent 9e39b7e commit 997c5c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions guessit/rules/properties/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def other(config): # pylint:disable=unused-argument,too-many-statements
rebulk.regex('ws', 'wide-?screen', value='Widescreen')
rebulk.regex('Re-?Enc(?:oded)?', value='Reencoded')

rebulk.string('Repack', 'Rerip', value='Proper',
tags=['streaming_service.prefix', 'streaming_service.suffix'])
rebulk.regex('Repack(?P<proper_count>\d*)', 'Rerip(?P<proper_count>\d*)', value={'other': 'Proper'},
tags=['streaming_service.prefix', 'streaming_service.suffix'])
rebulk.string('Proper', value='Proper',
tags=['has-neighbor', 'streaming_service.prefix', 'streaming_service.suffix'])

Expand Down Expand Up @@ -170,7 +170,12 @@ def when(self, matches, context): # pylint:disable=inconsistent-return-statemen

value = 0
for raw in raws.values():
value += 2 if 'real' in raw.tags else 1
if raw.children.named('proper_count', 0):
value += int(raw.children.named('proper_count', 0).value)
elif 'real' in raw.tags:
value += 2
else:
value += 1

proper_count_match.value = value
return proper_count_match
Expand Down Expand Up @@ -360,7 +365,7 @@ def when(self, matches, context):
predicate=lambda m: m.name == 'other' and 'at-end' in m.tags):
if (matches.holes(match.end, filepart.end, predicate=lambda m: m.value.strip(seps)) or
matches.range(match.end, filepart.end, predicate=lambda m: m.name not in (
'other', 'container'))):
'other', 'container'))):
to_remove.append(match)

return to_remove
Expand Down
4 changes: 4 additions & 0 deletions guessit/test/rules/other.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,7 @@
? Upscale
: other: Upscaled

? REPACK5
? ReRip5
: other: Proper
proper_count: 5

0 comments on commit 997c5c2

Please sign in to comment.