Skip to content

Commit

Permalink
#408: Fixes REAL and PROPER tags scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
ratoaq2 committed Feb 16, 2019
1 parent 240ca61 commit 53e8e86
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 3 deletions.
2 changes: 2 additions & 0 deletions guessit/config/options.json
Expand Up @@ -21,6 +21,7 @@
"ja",
"ko",
"nl",
"no",
"pl",
"pt",
"ro",
Expand All @@ -38,6 +39,7 @@
"de",
"he",
"it",
"no",
"por",
"rum",
"se",
Expand Down
26 changes: 24 additions & 2 deletions guessit/rules/properties/other.py
Expand Up @@ -35,11 +35,16 @@ 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('Proper', 'Repack', 'Rerip', value='Proper',
rebulk.string('Repack', 'Rerip', value='Proper',
tags=['streaming_service.prefix', 'streaming_service.suffix'])
rebulk.string('Proper', value='Proper',
tags=['has-neighbor', 'streaming_service.prefix', 'streaming_service.suffix'])

rebulk.regex('Real-Proper', 'Real-Repack', 'Real-Rerip', value='Proper',
tags=['streaming_service.prefix', 'streaming_service.suffix', 'real'])
rebulk.regex('Real', value='Proper',
tags=['has-neighbor', 'streaming_service.prefix', 'streaming_service.suffix', 'real'])

rebulk.string('Fix', 'Fixed', value='Fix', tags=['has-neighbor-before', 'has-neighbor-after',
'streaming_service.prefix', 'streaming_service.suffix'])
rebulk.string('Dirfix', 'Nfofix', 'Prooffix', value='Fix',
Expand Down Expand Up @@ -135,7 +140,7 @@ def validate_complete(match):

rebulk.rules(RenameAnotherToOther, ValidateHasNeighbor, ValidateHasNeighborAfter, ValidateHasNeighborBefore,
ValidateScreenerRule, ValidateMuxRule, ValidateHardcodedSubs, ValidateStreamingServiceNeighbor,
ValidateAtEnd, ProperCountRule)
ValidateAtEnd, ValidateReal, ProperCountRule)

return rebulk

Expand Down Expand Up @@ -355,3 +360,20 @@ def when(self, matches, context):
to_remove.append(match)

return to_remove


class ValidateReal(Rule):
"""
Validate Real
"""
consequence = RemoveMatch
priority = 64

def when(self, matches, context):
ret = []
for filepart in matches.markers.named('path'):
for match in matches.range(filepart.start, filepart.end, lambda m: m.name == 'other' and 'real' in m.tags):
if not matches.range(filepart.start, match.start):
ret.append(match)

return ret
2 changes: 1 addition & 1 deletion guessit/test/rules/other.yml
Expand Up @@ -48,7 +48,7 @@
proper_count: 3


? Proper
? Proper.720p
? +Repack
? +Rerip
: other: Proper
Expand Down
111 changes: 111 additions & 0 deletions guessit/test/various.yml
Expand Up @@ -1003,3 +1003,114 @@
year: 2011
container: mkv
type: movie

? Cleveland.Hustles.S01E03.Downward.Dogs.and.Proper.Pigs.720p.HDTV.x264-W4F
: title: Cleveland Hustles
season: 1
episode: 3
episode_title: Downward Dogs and Proper Pigs
screen_size: 720p
source: HDTV
video_codec: H.264
release_group: W4F
type: episode

? Pawn.Stars.S12E20.The.Pawn.Awakens.REAL.READ.NFO.720p.HDTV.x264-DHD
: title: Pawn Stars
season: 12
episode: 20
episode_title: The Pawn Awakens
other:
- Proper
- Read NFO
proper_count: 2
screen_size: 720p
source: HDTV
video_codec: H.264
release_group: DHD
type: episode

? Pawn.Stars.S12E22.Racing.Revolution.REAL.720p.HDTV.x264-DHD
: title: Pawn Stars
season: 12
episode: 22
episode_title: Racing Revolution
other: Proper
proper_count: 2
screen_size: 720p
source: HDTV
video_codec: H.264
release_group: DHD
type: episode

? Luksusfellen.S18E02.REAL.NORWEGiAN.720p.WEB.h264-NORPiLT
: title: Luksusfellen
season: 18
episode: 2
other: Proper
proper_count: 2
language: Norwegian
screen_size: 720p
source: Web
video_codec: H.264
release_group: NORPiLT
type: episode

? The.Exorcist.S02E07.REAL.FRENCH.720p.HDTV.x264-SH0W
: title: The Exorcist
season: 2
episode: 7
other: Proper
proper_count: 2
language: fr
screen_size: 720p
source: HDTV
video_codec: H.264
release_group: SH0W
type: episode

? Outrageous.Acts.of.Science.S05E02.Is.This.for.Real.720p.HDTV.x264-DHD
: title: Outrageous Acts of Science
season: 5
episode: 2
# corner case
# episode_title: Is This for Real
screen_size: 720p
source: HDTV
video_codec: H.264
release_group: DHD
type: episode

? How.the.Universe.Works.S06E08.Strange.Lives.of.Dwarf.Planets.REAL.720p.WEB.x264-DHD
: title: How the Universe Works
season: 6
episode: 8
episode_title: Strange Lives of Dwarf Planets
other: Proper
proper_count: 2
screen_size: 720p
source: Web
video_codec: H.264
release_group: DHD
type: episode

? Vampirina.S01E16.REAL.HDTV.x264-W4F
: title: Vampirina
season: 1
episode: 16
other: Proper
proper_count: 2
source: HDTV
video_codec: H.264
release_group: W4F
type: episode

? Test.S01E16.Some Real Episode Title.HDTV.x264-W4F
: title: Test
season: 1
episode: 16
episode_title: Some Real Episode Title
source: HDTV
video_codec: H.264
release_group: W4F
type: episode

0 comments on commit 53e8e86

Please sign in to comment.