From fcf0065135b491af6082c82410d68af4645e149e Mon Sep 17 00:00:00 2001 From: DDSRem <1448139087@qq.com> Date: Wed, 27 May 2026 22:12:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(embymetarefresh):=20=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E9=80=82=E9=85=8D=20zhconv=20=E4=B8=8E=20zhconv-rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 确保繁简转换在不同依赖环境下均可正常工作,并更新 v1.7.5 / v2.3.3 版本。 Co-authored-by: Cursor --- package.json | 3 ++- package.v2.json | 3 ++- plugins.v2/embymetarefresh/__init__.py | 22 ++++++++++++++++++---- plugins/embymetarefresh/__init__.py | 22 ++++++++++++++++++---- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0d601eb..f6f579c 100644 --- a/package.json +++ b/package.json @@ -491,11 +491,12 @@ "name": "Emby元数据刷新", "description": "定时刷新Emby媒体库元数据,演职人员中文。", "labels": "Emby", - "version": "1.7.4", + "version": "1.7.5", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png", "author": "thsrite", "level": 1, "history": { + "v1.7.5": "同时适配 zhconv 和 zhconv-rs", "v1.7.4": "获取tmdb图片使用PROXY_HOST代理", "v1.7.3": "优化剧集演员刮削", "v1.7.2": "优化剧集演员刮削", diff --git a/package.v2.json b/package.v2.json index cfbc9c6..898faf9 100644 --- a/package.v2.json +++ b/package.v2.json @@ -21,11 +21,12 @@ "name": "Emby元数据刷新", "description": "定时刷新Emby媒体库元数据,演职人员中文。", "labels": "Emby", - "version": "2.3.2", + "version": "2.3.3", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png", "author": "thsrite", "level": 1, "history": { + "v2.3.3": "同时适配 zhconv 和 zhconv-rs", "v2.3.2": "修复缓存序列化错误问题", "v2.3.1": "doumao yyds", "v2.3.0": "优化内存占用", diff --git a/plugins.v2/embymetarefresh/__init__.py b/plugins.v2/embymetarefresh/__init__.py index 3791321..061d210 100644 --- a/plugins.v2/embymetarefresh/__init__.py +++ b/plugins.v2/embymetarefresh/__init__.py @@ -15,7 +15,21 @@ from apscheduler.triggers.cron import CronTrigger from dateutil.parser import isoparse from requests import RequestException from sqlalchemy.orm import Session -from zhconv import zhconv + +try: + from zhconv import zhconv as _zhconv + + def _convert_to_zh_hans(text: str) -> str: + return _zhconv.convert(text, "zh-hans") +except ImportError: + try: + from zhconv_rs import zhconv as _zhconv_rs + + def _convert_to_zh_hans(text: str) -> str: + return _zhconv_rs(text, "zh-hans") + except ImportError: + def _convert_to_zh_hans(text: str) -> str: + return text from app import schemas from app.chain.tmdb import TmdbChain @@ -43,7 +57,7 @@ class EmbyMetaRefresh(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png" # 插件版本 - plugin_version = "2.3.2" + plugin_version = "2.3.3" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -924,8 +938,8 @@ class EmbyMetaRefresh(_PluginBase): if also_known_as: for name in also_known_as: if name and StringUtils.is_chinese(name): - # 使用cn2an将繁体转化为简体 - return zhconv.convert(name, "zh-hans") + # 使用 zhconv / zhconv-rs 将繁体转化为简体 + return _convert_to_zh_hans(name) except Exception as err: logger.error(f"获取人物中文名失败:{err}") return "" diff --git a/plugins/embymetarefresh/__init__.py b/plugins/embymetarefresh/__init__.py index 861bc1e..1517602 100644 --- a/plugins/embymetarefresh/__init__.py +++ b/plugins/embymetarefresh/__init__.py @@ -12,7 +12,21 @@ from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger from dateutil.parser import isoparse from requests import RequestException -from zhconv import zhconv + +try: + from zhconv import zhconv as _zhconv + + def _convert_to_zh_hans(text: str) -> str: + return _zhconv.convert(text, "zh-hans") +except ImportError: + try: + from zhconv_rs import zhconv as _zhconv_rs + + def _convert_to_zh_hans(text: str) -> str: + return _zhconv_rs(text, "zh-hans") + except ImportError: + def _convert_to_zh_hans(text: str) -> str: + return text from app import schemas from app.chain.tmdb import TmdbChain @@ -36,7 +50,7 @@ class EmbyMetaRefresh(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png" # 插件版本 - plugin_version = "1.7.4" + plugin_version = "1.7.5" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -596,8 +610,8 @@ class EmbyMetaRefresh(_PluginBase): if also_known_as: for name in also_known_as: if name and StringUtils.is_chinese(name): - # 使用cn2an将繁体转化为简体 - return zhconv.convert(name, "zh-hans") + # 使用 zhconv / zhconv-rs 将繁体转化为简体 + return _convert_to_zh_hans(name) except Exception as err: logger.error(f"获取人物中文名失败:{err}") return ""