From 3723cf8ac2a583f9150766febf794908f5b61166 Mon Sep 17 00:00:00 2001 From: 2Dou Date: Fri, 15 Aug 2025 09:54:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A2=9E=E5=8A=A0=E6=8E=92=E9=99=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/themoviedb/category.py | 43 +++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/app/modules/themoviedb/category.py b/app/modules/themoviedb/category.py index a1066e4b..4b4864af 100644 --- a/app/modules/themoviedb/category.py +++ b/app/modules/themoviedb/category.py @@ -108,6 +108,7 @@ class CategoryHelper(metaclass=WeakSingleton): return "" if not categorys: return "" + for key, item in categorys.items(): if not item: return key @@ -134,23 +135,41 @@ class CategoryHelper(metaclass=WeakSingleton): else: info_values = [str(info_value).upper()] - if value.find(",") != -1: - # , 分隔多个值 - values = [str(val).upper() for val in value.split(",") if val] - elif value.find("-") != -1: - # - 表示范围,仅限于数字 - value_begin = value.split("-")[0] - value_end = value.split("-")[1] + values = [] + invert_values = [] + + # 如果有 "," 进行分割 + values = [str(val) for val in value.split(",") if val] + + expanded_values = [] + for v in values: + if "-" not in v: + expanded_values.append(v) + continue + + # - 表示范围 + value_begin, value_end = v.split("-", 1) + + prefix = "" + if value_begin.startswith('!'): + prefix = '!' + value_begin = value_begin[1:] + if value_begin.isdigit() and value_end.isdigit(): # 数字范围 - values = [str(val) for val in range(int(value_begin), int(value_end) + 1)] + expanded_values.extend(f"{prefix}{val}" for val in range(int(value_begin), int(value_end) + 1)) else: # 字符串范围 - values = [str(value_begin), str(value_end)] - else: - values = [str(value).upper()] + expanded_values.extend([f"{prefix}{value_begin}", f"{prefix}{value_end}"]) - if not set(values).intersection(set(info_values)): + values = list(map(str.upper, expanded_values)) + + invert_values = [val[1:] for val in values if val.startswith('!')] + values = [val for val in values if not val.startswith('!')] + + if values and not set(values).intersection(set(info_values)): + match_flag = False + if invert_values and set(invert_values).intersection(set(info_values)): match_flag = False if match_flag: return key From d3ba0fa48782ca2c9be373a5b26ce89cb448b2b9 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 3 Sep 2025 11:58:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20category.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- app/modules/themoviedb/category.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/modules/themoviedb/category.py b/app/modules/themoviedb/category.py index 4b4864af..9f2e29f1 100644 --- a/app/modules/themoviedb/category.py +++ b/app/modules/themoviedb/category.py @@ -138,7 +138,7 @@ class CategoryHelper(metaclass=WeakSingleton): values = [] invert_values = [] - # 如果有 "," 进行分割 + # 如果有 "," 进行分割 values = [str(val) for val in value.split(",") if val] expanded_values = []