From 8fd004b51aa506903bda14c4a562f81691fdaf25 Mon Sep 17 00:00:00 2001 From: Rato Date: Sat, 15 Jul 2017 22:09:08 +0200 Subject: [PATCH] #469: Detect Ultra HD Bluray --- HISTORY.rst | 76 ++++++++++++++++++++++++- docs/properties.rst | 2 +- guessit/rules/properties/other.py | 2 +- guessit/rules/properties/screen_size.py | 4 +- guessit/rules/properties/source.py | 61 +++++++++++++++++++- guessit/test/episodes.yml | 13 +++++ guessit/test/movies.yml | 36 ++++++++++-- guessit/test/rules/source.yml | 30 ++++++++++ 8 files changed, 212 insertions(+), 12 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 70849b4..d6ab975 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,7 +4,81 @@ History 3.0.0 (unreleased) ------------------ -- Nothing changed yet. +- Renamed `format` property to `source`. +- `source` property `Cam` is now `Camera` or `HD Camera` +- `source` property `Telesync` is now `Telesync` or `HD Telesync` +- `source` property `PPV` is now `Pay-per-view` +- `source` property `DVB` is now `Digital TV` +- `source` property `VOD` is now `Video on Demand` +- `source` property `WEBRip` is now `Web` with additional property `other`: `Rip` +- `source` property `WEB-DL` is now `Web` +- `source` property `AHDTV` is now `Analogue HDTV` +- `source` property `UHDTV` is now `Ultra HDTV` +- `source` property `HDTC` is now `HD Telecine` +- `screen_size` property `360i` was added. +- `screen_size` property `480i` was added. +- `screen_size` property `576i` was added. +- `screen_size` property `900i` was added. +- `screen_size` property `4K` is now `2160p` +- `screen_size` property `4320p` was added. +- `video_codec` property `h264` is now `H.264` +- `video_codec` property `h265` is now `H.265` +- `video_codec` property `Mpeg2` is now `MPEG-2` +- `video_codec` property `Real` is now `RealVideo` +- `video_codec` property `XviD` is now `Xvid` +- `video_profile` property `BP` is now `Baseline`. +- `video_profile` property `HP` is now `High`. +- `video_profile` property `XP` is now `Extended`. +- `video_profile` property `MP` is now `Main`. +- `video_profile` property `Hi422P` is now `High 4:2:2`. +- `video_profile` property `Hi444PP` is now `High 4:4:4 Predictive`. +- `video_profile` property `High 10` was added. +- `video_profile` property `8bit` was removed. `8bit` is detected as `color_depth`: `8-bit` +- `video_profile` property `10bit` was removed. `10bit` is detected as `color_depth`: `10-bit` +- `audio_codec` property `DTS-HD` was added. +- `audio_codec` property `AC3` is now `Dolby Digital` +- `audio_codec` property `EAC3` is now `Dolby Digital Plus` +- `audio_codec` property `TrueHD` is now `Dolby TrueHD` +- `audio_codec` property `DolbyAtmos` is now `Dolby Atmos`. +- `audio_profile` property `HE` is now `High Efficiency`. +- `audio_profile` property `LC` is now `Low Complexity`. +- `audio_profile` property `HQ` is now `High Quality`. +- `audio_profile` property `HDMA` is now `Master Audio`. +- `edition` property `Collector Edition` is now `Collector` +- `edition` property `Special Edition` is now `Special` +- `edition` property `Criterion Edition` is now `Criterion` +- `edition` property `Deluxe Edition` is now `Deluxe` +- `edition` property `Limited Edition` is now `Limited` +- `edition` property `Theatrical Edition` is now `Theatrical` +- `edition` property `Director's Definitive Cut` was added. +- `episode_details` property `Oav` and `Ova` were removed. They are now `other: Original Animated Video` +- `episode_details` property `Omake` is now `Extras` +- `episode_details` property `Final` was added. +- `other` property `Rip` was added. +- `other` property `DDC` was removed. `DDC` is now `edition`: `Director's Definitive Cut` +- `other` property `CC` was removed. `CC` is now `edition`: `Criterion` +- `other` property `FINAL` was removed. `FINAL` is now `episode_details`: `Final` +- `other` property `Original Animated Video` was added. +- `other` property `OV` is now `Original Video` +- `other` property `AudioFix` is now `Audio Fixed` +- `other` property `SyncFix` is now `Sync Fixed` +- `other` property `DualAudio` is now `Dual Audio` +- `other` property `Fansub` is now `Fan Subtitled` +- `other` property `Fastsub` is now `Fast Subtitled` +- `other` property `FullHD` is now `Full HD` +- `other` property `UltraHD` is now `Ultra HD` +- `other` property `mHD` and `HDLight` are now `Micro HD` +- `other` property `HQ` is now `High Quality` +- `other` property `HR` is now `High Resolution` +- `other` property `LD` is now `Line Dubbed` +- `other` property `MD` is now `Mic Dubbed` +- `other` property `Low Definition` was added. +- `other` property `LiNE` is now `Line Audio` +- `other` property `R5` is now `Region 5` +- `other` property `Region C` was added. +- `other` property `ReEncoded` is now `Reencoded` +- `other` property `WideScreen` is now `Widescreen` +- Added `Ultra HD Blu-ray` as new `source` possible value. 2.1.4 (2017-06-01) diff --git a/docs/properties.rst b/docs/properties.rst index 7aec7db..cda553e 100644 --- a/docs/properties.rst +++ b/docs/properties.rst @@ -137,7 +137,7 @@ Video properties - ``Analogue HDTV``, ``Blu-ray``, ``Camera``, ``Digital TV``, ``DVD``, ``HD Camera``, ``HD Telecine``, ``HD Telesync``, ``HD-DVD``, ``HDTV``, ``Pay-per-view``, ``Satellite``, ``Telecine``, ``Telesync``, ``TV``, - ``Ultra HDTV``, ``VHS``, ``Video on Demand``, ``Web``, ``Workprint`` + ``Ultra HD Blu-ray``, ``Ultra HDTV``, ``VHS``, ``Video on Demand``, ``Web``, ``Workprint`` - **screen_size** diff --git a/guessit/rules/properties/other.py b/guessit/rules/properties/other.py index 56a1806..d5858ca 100644 --- a/guessit/rules/properties/other.py +++ b/guessit/rules/properties/other.py @@ -71,7 +71,7 @@ def other(): for value in ('Screener', 'Remux', '3D', 'PAL', 'SECAM', 'NTSC', 'XXX'): rebulk.string(value, value=value) - rebulk.string('HQ', value='High Quality') + rebulk.string('HQ', value='High Quality', tags='uhdbluray-neighbor') rebulk.string('HR', value='High Resolution') rebulk.string('LD', value='Line Dubbed') rebulk.string('MD', value='Mic Dubbed') diff --git a/guessit/rules/properties/screen_size.py b/guessit/rules/properties/screen_size.py index 6671b25..f690c8b 100644 --- a/guessit/rules/properties/screen_size.py +++ b/guessit/rules/properties/screen_size.py @@ -68,7 +68,7 @@ def screen_size(): class ScreenSizeOnlyOne(Rule): """ - Keep a single screen_size pet filepath part. + Keep a single screen_size per filepath part. """ consequence = RemoveMatch @@ -77,7 +77,7 @@ class ScreenSizeOnlyOne(Rule): for filepart in matches.markers.named('path'): screensize = list(reversed(matches.range(filepart.start, filepart.end, lambda match: match.name == 'screen_size'))) - if len(screensize) > 1: + if len(screensize) > 1 and len(set((match.value for match in screensize))) > 1: to_remove.extend(screensize[1:]) return to_remove diff --git a/guessit/rules/properties/source.py b/guessit/rules/properties/source.py index 6855f8f..c26c239 100644 --- a/guessit/rules/properties/source.py +++ b/guessit/rules/properties/source.py @@ -3,11 +3,14 @@ """ source property """ +import copy + from rebulk.remodule import re -from rebulk import Rebulk, RemoveMatch, Rule +from rebulk import AppendMatch, Rebulk, RemoveMatch, Rule -from ..common import dash +from .audio_codec import HqConflictRule +from ..common import dash, seps from ..common.validators import seps_before, seps_after @@ -95,6 +98,8 @@ def source(): rebulk.regex(*build_source_pattern('(?PBR)', suffix=rip_suffix), # BRRip value={'source': 'Blu-ray', 'other': 'Rip', 'another': 'Reencoded'}) + rebulk.regex(*build_source_pattern('Ultra-?Blu-?ray', 'Blu-?ray-?Ultra'), value='Ultra HD Blu-ray') + rebulk.regex(*build_source_pattern('AHDTV'), value='Analogue HDTV') rebulk.regex(*build_source_pattern('UHD-?TV', suffix=rip_optional_suffix), conflict_solver=demote_other, value={'source': 'Ultra HDTV', 'other': 'Rip'}) @@ -106,11 +111,61 @@ def source(): rebulk.regex(*build_source_pattern('DSR?', 'SAT', suffix=rip_suffix), value={'source': 'Satellite', 'other': 'Rip'}) - rebulk.rules(ValidateSource) + rebulk.rules(ValidateSource, UltraHdBlurayRule) return rebulk +class UltraHdBlurayRule(Rule): + """ + Replace other:Ultra HD and source:Blu-ray with source:Ultra HD Blu-ray + """ + dependency = HqConflictRule + consequence = [RemoveMatch, AppendMatch] + + @classmethod + def find_ultrahd(cls, matches, start, end, index): + """Find Ultra HD match.""" + return matches.range(start, end, index=index, predicate=( + lambda m: not m.private and m.name == 'other' and m.value == 'Ultra HD' + )) + + @classmethod + def validate_range(cls, matches, start, end): + """Validate no holes or invalid matches exist in the specified range.""" + return ( + not matches.holes(start, end, predicate=lambda m: m.value.strip(seps)) and + not matches.range(start, end, predicate=( + lambda m: not m.private and ( + m.name not in ('screen_size', 'color_depth') and ( + m.name != 'other' or 'uhdbluray-neighbor' not in m.tags)))) + ) + + def when(self, matches, context): + to_remove = [] + to_append = [] + for filepart in matches.markers.named('path'): + for match in matches.range(filepart.start, filepart.end, predicate=( + lambda m: not m.private and m.name == 'source' and m.value == 'Blu-ray')): + other = self.find_ultrahd(matches, filepart.start, match.start, -1) + if not other or not self.validate_range(matches, other.end, match.start): + other = self.find_ultrahd(matches, match.end, filepart.end, 0) + if not other or not self.validate_range(matches, match.end, other.start): + if not matches.range(filepart.start, filepart.end, predicate=( + lambda m: m.name == 'screen_size' and m.value == '2160p')): + continue + + if other: + other.private = True + + new_source = copy.copy(match) + new_source.value = 'Ultra HD Blu-ray' + to_remove.append(match) + to_append.append(new_source) + + return to_remove, to_append + + class ValidateSource(Rule): """ Validate source with screener property, with video_codec property or separated diff --git a/guessit/test/episodes.yml b/guessit/test/episodes.yml index 7c7bf63..8b18f19 100644 --- a/guessit/test/episodes.yml +++ b/guessit/test/episodes.yml @@ -4040,3 +4040,16 @@ release_group: TBS container: mkv type: episode + +? Planet.Earth.II.S01.2160p.UHD.BluRay.HDR.DTS-HD.MA5.1.x265-ULTRAHDCLUB +: title: Planet Earth II + season: 1 + screen_size: 2160p + source: Ultra HD Blu-ray +# other: High Dynamic Range + audio_codec: DTS-HD + audio_profile: Master Audio + audio_channels: '5.1' + video_codec: H.265 + release_group: ULTRAHDCLUB + type: episode diff --git a/guessit/test/movies.yml b/guessit/test/movies.yml index 055098c..8c3c83d 100644 --- a/guessit/test/movies.yml +++ b/guessit/test/movies.yml @@ -902,8 +902,7 @@ year: 2016 language: mul screen_size: 2160p - other: Ultra HD - source: Blu-ray + source: Ultra HD Blu-ray video_codec: H.265 color_depth: 10-bit audio_codec: [DTS-HD, Dolby Atmos] @@ -932,10 +931,9 @@ ? Suicide Squad EXTENDED (2016) 2160p 4K UltraHD Blu-Ray x265 (HEVC 10bit BT709) Dolby Atmos 7.1 -DDR : title: Suicide Squad edition: Extended - other: Ultra HD year: 2016 screen_size: 2160p - source: Blu-ray + source: Ultra HD Blu-ray video_codec: H.265 color_depth: 10-bit audio_codec: Dolby Atmos @@ -1185,3 +1183,33 @@ release_group: MrGrey type: movie +? The Martian 2015 Multi 2160p 4K UHD Bluray HEVC10 SDR DTSHD 7.1 -Zeus +: title: The Martian + year: 2015 + language: mul + screen_size: 2160p + source: Ultra HD Blu-ray + video_codec: H.265 + color_depth: 10-bit + audio_codec: DTS-HD + audio_channels: '7.1' + release_group: Zeus + type: movie + +? Fantastic Beasts and Where to Find Them 2016 Multi 2160p UHD BluRay HEVC HDR Atmos7.1-DDR +: title: Fantastic Beasts and Where to Find Them + year: 2016 + language: mul + screen_size: 2160p + source: Ultra HD Blu-ray + video_codec: H.265 + audio_codec: Dolby Atmos + audio_channels: '7.1' + release_group: DDR + type: movie + +? Life of Pi 2012 2160p 4K BluRay HDR10 HEVC BT2020 DTSHD 7.1 subs -DDR +: title: Life of Pi + year: 2012 + screen_size: 2160p + source: Ultra HD Blu-ray \ No newline at end of file diff --git a/guessit/test/rules/source.yml b/guessit/test/rules/source.yml index 303c598..e1b8c13 100644 --- a/guessit/test/rules/source.yml +++ b/guessit/test/rules/source.yml @@ -281,3 +281,33 @@ ? -UHDTV : source: Ultra HDTV other: Rip + +? UHD Bluray +? UHD 2160p Bluray +? UHD 8bit Bluray +? UHD HQ 8bit Bluray +? Ultra Bluray +? Ultra HD Bluray +? Bluray ULTRA +? Bluray Ultra HD +? Bluray UHD +? 4K Bluray +? 2160p Bluray +? -HD Bluray +? -AMERICAN ULTRA (2015) 1080p Bluray +? -American.Ultra.2015.BRRip +? -BRRip XviD AC3-ULTRAS +? -UHD Proper Bluray +: source: Ultra HD Blu-ray + +? UHD.BRRip +? UHD.2160p.BRRip +? BRRip.2160p.UHD +? BRRip.[4K-2160p-UHD] +: source: Ultra HD Blu-ray + other: [Reencoded, Rip] + +? UHD.2160p.BDRip +? BDRip.[4K-2160p-UHD] +: source: Ultra HD Blu-ray + other: Rip