mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-03 06:29:55 +08:00
@@ -15,6 +15,17 @@ class CustomizationMatcher(metaclass=Singleton):
|
||||
self.customization = None
|
||||
self.custom_separator = None
|
||||
|
||||
@staticmethod
|
||||
def _normalize_customization(customization):
|
||||
"""
|
||||
规范化自定义占位符配置,兼容历史字符串与列表两种保存格式。
|
||||
"""
|
||||
if isinstance(customization, str):
|
||||
customization = customization.replace("\n", ";").replace("|", ";").strip(";").split(";")
|
||||
if not customization:
|
||||
return []
|
||||
return list(filter(None, customization))
|
||||
|
||||
def match(self, title=None):
|
||||
"""
|
||||
:param title: 资源标题或文件名
|
||||
@@ -22,14 +33,14 @@ class CustomizationMatcher(metaclass=Singleton):
|
||||
"""
|
||||
if not title:
|
||||
return ""
|
||||
if not self.customization:
|
||||
# 自定义占位符
|
||||
customization = self.systemconfig.get(SystemConfigKey.Customization)
|
||||
if not customization:
|
||||
return ""
|
||||
if isinstance(customization, str):
|
||||
customization = customization.replace("\n", ";").replace("|", ";").strip(";").split(";")
|
||||
self.customization = "|".join([f"({item})" for item in customization])
|
||||
# 自定义占位符需要跟随系统配置实时生效,避免单例缓存导致保存后仍沿用旧规则。
|
||||
customization = self._normalize_customization(
|
||||
self.systemconfig.get(SystemConfigKey.Customization)
|
||||
)
|
||||
if not customization:
|
||||
self.customization = None
|
||||
return ""
|
||||
self.customization = "|".join([f"({item})" for item in customization])
|
||||
|
||||
customization_re = re.compile(r"%s" % self.customization)
|
||||
# 处理重复多次的情况,保留先后顺序(按添加自定义占位符的顺序)
|
||||
|
||||
Reference in New Issue
Block a user