From c21a31e63c06495ffbdb8bb697e96791577bce61 Mon Sep 17 00:00:00 2001 From: DDSRem <73049927+DDSRem@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:55:08 +0800 Subject: [PATCH] feat: configuration enhancements --- all_in_one.sh | 6 --- glue_python/aliyunopentoken/README.md | 9 ++++- .../strmassistanthelper.py | 40 ++++++++++++------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/all_in_one.sh b/all_in_one.sh index 055677e..999f898 100644 --- a/all_in_one.sh +++ b/all_in_one.sh @@ -511,12 +511,6 @@ function qrcode_mode_choose() { else extra_parameters="--api_url=api-cf.nn.ci" INFO "使用 api-cf.nn.ci 地址" - # elif curl -Is https://api-cf.nn.ci/alist/ali_open/qr | head -n 1 | grep -q '200'; then - # extra_parameters="--api_url=api-cf.nn.ci" - # INFO "使用 api-cf.nn.ci 地址" - # else - # extra_parameters="--api_url=aliyundrive-oauth.messense.me" - # INFO "使用 aliyundrive-oauth.messense.me 地址" fi elif [ "${2}" == "/aliyuntoken/aliyuntoken.py" ]; then if curl -Is https://api.xhofe.top/alist/ali/qr | head -n 1 | grep -q '200'; then diff --git a/glue_python/aliyunopentoken/README.md b/glue_python/aliyunopentoken/README.md index 6a7a7cb..ce80d6f 100644 --- a/glue_python/aliyunopentoken/README.md +++ b/glue_python/aliyunopentoken/README.md @@ -3,4 +3,11 @@ - api-cf.nn.ci - api.xhofe.top - aliyundrive-oauth.messense.me -- openapi.aliyundrive.com \ No newline at end of file +- openapi.aliyundrive.com + +## Use + +```shell +Alist Open Token --> --api_url=api-cf.nn.ci/api.xhofe.top +WebDav Open Token --> --api_url=aliyundrive-oauth.messense.me +``` \ No newline at end of file diff --git a/glue_python/strmassistanthelper/strmassistanthelper.py b/glue_python/strmassistanthelper/strmassistanthelper.py index 4268365..468439a 100644 --- a/glue_python/strmassistanthelper/strmassistanthelper.py +++ b/glue_python/strmassistanthelper/strmassistanthelper.py @@ -2,6 +2,7 @@ # pylint: disable=C0103 # pylint: disable=C0114 +import json import logging import sys import shutil @@ -47,6 +48,25 @@ def move_and_replace_config(file_name: str): move_and_replace_file(_source_file, _dst_file_path) +def set_and_info_config(): + """ + 替换配置文件并输出信息 + """ + if Path(f"{BASE_CONFIG_PATH}/plugins/configurations/Strm Assistant.json").exists(): + with open(f"{BASE_CONFIG_PATH}/plugins/configurations/Strm Assistant.json", encoding="utf-8") as file: + data = json.load(file) + if data["ModOptions"]["EnhanceChineseSearch"] == "true": + logging.info("中文搜索增强已开启") + else: + logging.info("中文搜索增强未开启") + for file in [ + "Strm Assistant.json", + "Strm Assistant_MediaInfoExtractOptions.json", + "Strm Assistant_ExperienceEnhanceOptions.json", + ]: + move_and_replace_config(file) + + logging.basicConfig( format="%(asctime)s %(levelname)s %(message)s", level=logging.INFO, @@ -58,25 +78,15 @@ BASE_CONFIG_PATH = "/media/config" BASE_DATA_PATH = "/strmassistanthelper" version = get_file_version(f"{BASE_CONFIG_PATH}/plugins/StrmAssistant.dll") -if version: - if version > "2.0.0.0": - for file in [ - "Strm Assistant.json", - "Strm Assistant_MediaInfoExtractOptions.json", - "Strm Assistant_ExperienceEnhanceOptions.json", - ]: - move_and_replace_config(file) +new_version = get_file_version(f"{BASE_DATA_PATH}/StrmAssistant.dll") +if version and new_version: + if version >= new_version: + set_and_info_config() else: source_file = Path(f"{BASE_DATA_PATH}/StrmAssistant.dll") dst_file_path = Path(f"{BASE_CONFIG_PATH}/plugins/StrmAssistant.dll") - new_version = get_file_version(f"{BASE_DATA_PATH}/StrmAssistant.dll") logging.info("更新 神医助手 插件:%s --> %s", version, new_version) move_and_replace_file(source_file, dst_file_path) - for file in [ - "Strm Assistant.json", - "Strm Assistant_MediaInfoExtractOptions.json", - "Strm Assistant_ExperienceEnhanceOptions.json", - ]: - move_and_replace_config(file) + set_and_info_config() else: logging.info("获取 StrmAssistant 版本失败!")