From 51e00217947d8b993bcfb091b012da803245f698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Alvergnat?= Date: Wed, 3 Feb 2021 22:26:54 +0100 Subject: [PATCH] fix(streaming_service): add iT keyword support for iTunes (#669) --- guessit/config/options.json | 5 ++++- guessit/rules/properties/streaming_service.py | 13 ++++++++++--- guessit/test/streaming_services.yaml | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/guessit/config/options.json b/guessit/config/options.json index da7c7030..ca33d6c5 100644 --- a/guessit/config/options.json +++ b/guessit/config/options.json @@ -490,7 +490,10 @@ "Hulu": "HULU", "Investigation Discovery": "ID", "IFC": "IFC", - "iTunes": "iTunes", + "iTunes": [ + "iTunes", + {"pattern": "iT", "ignore_case": false} + ], "ITV": "ITV", "Knowledge Network": "KNOW", "Lifetime": "LIFE", diff --git a/guessit/rules/properties/streaming_service.py b/guessit/rules/properties/streaming_service.py index 1d42070f..b27fc440 100644 --- a/guessit/rules/properties/streaming_service.py +++ b/guessit/rules/properties/streaming_service.py @@ -30,10 +30,17 @@ def streaming_service(config): # pylint: disable=too-many-statements,unused-arg for value, items in config.items(): patterns = items if isinstance(items, list) else [items] for pattern in patterns: - if pattern.startswith(regex_prefix): - rebulk.regex(pattern[len(regex_prefix):], value=value) + if isinstance(pattern, dict): + pattern_value = pattern.pop('pattern') + kwargs = pattern + pattern = pattern_value else: - rebulk.string(pattern, value=value) + kwargs = {} + regex = kwargs.pop('regex', False) + if regex or pattern.startswith(regex_prefix): + rebulk.regex(pattern[len(regex_prefix):], value=value, **kwargs) + else: + rebulk.string(pattern, value=value, **kwargs) rebulk.rules(ValidateStreamingService) diff --git a/guessit/test/streaming_services.yaml b/guessit/test/streaming_services.yaml index 35063992..227d72d7 100644 --- a/guessit/test/streaming_services.yaml +++ b/guessit/test/streaming_services.yaml @@ -607,6 +607,7 @@ release_group: CasStudio type: episode +? Suits.S07E01.1080p.iT.WEB-DL.DD5.1.H.264-VLAD.mkv ? Suits.S07E01.1080p.iTunes.WEB-DL.DD5.1.H.264-VLAD.mkv : title: Suits season: 7