From 53e8e8626e9b6cfd86251a05e2f07f35bb32dada Mon Sep 17 00:00:00 2001 From: Rato Date: Sat, 16 Feb 2019 19:27:17 +0100 Subject: [PATCH] #408: Fixes REAL and PROPER tags scenarios --- guessit/config/options.json | 2 + guessit/rules/properties/other.py | 26 ++++++- guessit/test/rules/other.yml | 2 +- guessit/test/various.yml | 111 ++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+), 3 deletions(-) diff --git a/guessit/config/options.json b/guessit/config/options.json index 9945a63..9b35200 100644 --- a/guessit/config/options.json +++ b/guessit/config/options.json @@ -21,6 +21,7 @@ "ja", "ko", "nl", + "no", "pl", "pt", "ro", @@ -38,6 +39,7 @@ "de", "he", "it", + "no", "por", "rum", "se", diff --git a/guessit/rules/properties/other.py b/guessit/rules/properties/other.py index 57f9608..2d9cd5b 100644 --- a/guessit/rules/properties/other.py +++ b/guessit/rules/properties/other.py @@ -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', @@ -135,7 +140,7 @@ def other(config): # pylint:disable=unused-argument,too-many-statements rebulk.rules(RenameAnotherToOther, ValidateHasNeighbor, ValidateHasNeighborAfter, ValidateHasNeighborBefore, ValidateScreenerRule, ValidateMuxRule, ValidateHardcodedSubs, ValidateStreamingServiceNeighbor, - ValidateAtEnd, ProperCountRule) + ValidateAtEnd, ValidateReal, ProperCountRule) return rebulk @@ -355,3 +360,20 @@ class ValidateAtEnd(Rule): 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 diff --git a/guessit/test/rules/other.yml b/guessit/test/rules/other.yml index 34e9032..447f178 100644 --- a/guessit/test/rules/other.yml +++ b/guessit/test/rules/other.yml @@ -48,7 +48,7 @@ proper_count: 3 -? Proper +? Proper.720p ? +Repack ? +Rerip : other: Proper diff --git a/guessit/test/various.yml b/guessit/test/various.yml index 8ee7351..cf0e661 100644 --- a/guessit/test/various.yml +++ b/guessit/test/various.yml @@ -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