From 69c5741b89372d39594af2893423aa05906ab187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Alvergnat?= Date: Sat, 6 Feb 2021 00:38:00 +0100 Subject: [PATCH] fix(options): fix custom options.json groups starting/ending (#671) --- guessit/config/options.json | 4 ++-- guessit/rules/markers/groups.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/guessit/config/options.json b/guessit/config/options.json index 5a343bcb..fe695f3e 100644 --- a/guessit/config/options.json +++ b/guessit/config/options.json @@ -48,8 +48,8 @@ "sub" ], "groups": { - "starting": "([{", - "ending": ")]}" + "starting": "([{第", + "ending": ")]}話" }, "audio_codec": { "audio_channels": { diff --git a/guessit/rules/markers/groups.py b/guessit/rules/markers/groups.py index 4716d15d..ac66f044 100644 --- a/guessit/rules/markers/groups.py +++ b/guessit/rules/markers/groups.py @@ -5,6 +5,7 @@ """ from rebulk import Rebulk +from ...options import ConfigurationException def groups(config): """ @@ -21,6 +22,9 @@ def groups(config): starting = config['starting'] ending = config['ending'] + if len(starting) != len(ending): + raise ConfigurationException("Starting and ending groups must have the same length") + def mark_groups(input_string): """ Functional pattern to mark groups (...), [...] and {...}. @@ -28,7 +32,7 @@ def mark_groups(input_string): :param input_string: :return: """ - openings = ([], [], []) + openings = ([], ) * len(starting) i = 0 ret = []