规范插件的日志输出

This commit is contained in:
x1ao4 2025-05-19 17:02:50 +08:00
parent 62a514b597
commit 0c6274395d
7 changed files with 59 additions and 58 deletions

View File

@ -52,13 +52,13 @@ class Alist:
response = response.json()
if response.get("code") == 200:
print(
f"Alist刷新: {response.get('data',[])[1].get('value','')} {response.get('data',[])[0].get('value','')}"
f"AList 刷新: {response.get('data',[])[1].get('value','')} {response.get('data',[])[0].get('value','')}"
)
return True
else:
print(f"Alist刷新: 连接失败{response.get('message')}")
print(f"AList 刷新: 连接失败 {response.get('message')}")
except requests.exceptions.RequestException as e:
print(f"获取Alist信息出错: {e}")
print(f"获取 AList 信息出错: {e}")
return False
def storage_id_to_path(self, storage_id):
@ -69,7 +69,7 @@ class Alist:
storage_mount_path, quark_root_dir = match.group(1), match.group(2)
file_list = self.get_file_list(storage_mount_path)
if file_list.get("code") != 200:
print(f"Alist刷新: 获取挂载路径失败{file_list.get('message')}")
print(f"AList 刷新: 获取挂载路径失败 {file_list.get('message')}")
return False, (None, None)
# 2. 检查是否数字,调用 Alist API 获取存储信息
elif re.match(r"^\d+$", storage_id):
@ -84,12 +84,12 @@ class Alist:
)
elif storage_info["driver"] == "QuarkTV":
print(
f"Alist刷新: [QuarkTV]驱动⚠️ storage_id请手动填入 /Alist挂载路径:/Quark目录路径"
f"AList 刷新: [QuarkTV] 驱动 ⚠️ storage_id 请手动填入 /Alist挂载路径:/Quark目录路径"
)
else:
print(f"Alist刷新: 不支持[{storage_info['driver']}]驱动 ❌")
print(f"AList 刷新: 不支持 [{storage_info['driver']}] 驱动 ❌")
else:
print(f"Alist刷新: storage_id[{storage_id}]格式错误")
print(f"AList 刷新: storage_id [{storage_id}] 格式错误 ")
# 返回结果
if storage_mount_path and quark_root_dir:
return True, (storage_mount_path, quark_root_dir)
@ -107,28 +107,28 @@ class Alist:
if data.get("code") == 200:
return data.get("data", [])
else:
print(f"Alist刷新: 存储{storage_id}连接失败{data.get('message')}")
print(f"AList 刷新: 存储 {storage_id} 连接失败 {data.get('message')}")
except Exception as e:
print(f"Alist刷新: 获取Alist存储出错 {e}")
print(f"AList 刷新: 获取 AList 存储出错 {e}")
return []
def refresh(self, path):
data = self.get_file_list(path, True)
if data.get("code") == 200:
print(f"📁 Alist刷新目录[{path}] 成功")
print(f"📁 AList 刷新: 目录 [{path}] 成功 ")
return data.get("data")
elif "object not found" in data.get("message", ""):
# 如果是根目录就不再往上查找
if path == "/" or path == self.storage_mount_path:
print(f"📁 Alist刷新根目录不存在请检查 Alist 配置")
print(f"📁 AList 刷新: 根目录不存在,请检查 AList 配置")
return False
# 获取父目录
parent_path = os.path.dirname(path)
print(f"📁 Alist刷新[{path}] 不存在,转父目录 [{parent_path}]")
print(f"📁 AList 刷新: [{path}] 不存在,转父目录 [{parent_path}]")
# 递归刷新父目录
return self.refresh(parent_path)
else:
print(f"📁 Alist刷新失败{data.get('message')}")
print(f"📁 AList 刷新: 失败 {data.get('message')}")
def get_file_list(self, path, force_refresh=False):
url = f"{self.url}/api/fs/list"
@ -145,7 +145,7 @@ class Alist:
response.raise_for_status()
return response.json()
except Exception as e:
print(f"📁 Alist刷新: 获取文件列表出错{e}")
print(f"📁 AList 刷新: 获取文件列表出错 {e}")
return {}
def get_root_folder_full_path(self, cookie, pdir_fid):
@ -178,5 +178,5 @@ class Alist:
path = f"{path}/{item['file_name']}"
return path
except Exception as e:
print(f"Alist刷新: 获取Quark路径出错 {e}")
print(f"AList 刷新: 获取 Quark 路径出错 {e}")
return ""

View File

@ -2,7 +2,7 @@ import re
import requests
"""
配合 alist-strm 项目触发特定配置运行
配合 Alist-Strm 项目触发特定配置运行
https://github.com/tefuirZ/alist-strm
"""
@ -47,12 +47,12 @@ class Alist_strm:
for item in matchs
if item[0] in config_id_str.split(",")
]
print(f"alist-strm配置运行: {config_name}")
print(f"Alist-Strm 配置运行: {config_name}")
return True
else:
print(f"alist-strm配置运行: 匹配失败❌,请检查网络连通和cookie有效性")
print(f"Alist-Strm 配置运行: 匹配失败 ❌ 请检查网络连通和cookie有效性")
except Exception as e:
print(f"获取alist-strm配置信息出错: {e}")
print(f"获取 Alist-Strm 配置信息出错: {e}")
return False
def run_selected_configs(self, selected_configs_str):
@ -61,7 +61,7 @@ class Alist_strm:
try:
selected_configs = [int(x.strip()) for x in selected_configs_str.split(",")]
except ValueError:
print("🔗 alist-strm配置运行: 出错❌ id应以,分割")
print("🔗 Alist-Strm 配置运行: 出错 ❌ ID 应以 , 分割")
return False
data = [("selected_configs", config_id) for config_id in selected_configs]
data.append(("action", "run_selected"))
@ -73,10 +73,10 @@ class Alist_strm:
match = re.search(r'role="alert">\s*([^<]+)\s*<button', html_content)
if match:
alert = match.group(1).strip()
print(f"🔗 alist-strm配置运行: {alert}")
print(f"🔗 Alist-Strm 配置运行: {alert} ")
return True
else:
print(f"🔗 alist-strm配置运行: 失败")
print(f"🔗 Alist-Strm 配置运行: 失败 ")
except Exception as e:
print(f"Error: {e}")
return False

View File

@ -74,10 +74,10 @@ class Emby:
"POST", url, headers=headers, params=querystring
)
if response.text == "":
print(f"🎞️ 刷新Emby媒体库成功")
print(f"🎞️ 刷新 Emby 媒体库: 成功 ")
return True
else:
print(f"🎞️ 刷新Emby媒体库{response.text}")
print(f"🎞️ 刷新 Emby 媒体库: {response.text} ")
except Exception as e:
print(f"刷新 Emby 媒体库出错: {e}")
return False
@ -106,11 +106,11 @@ class Emby:
for item in response["Items"]:
if item["IsFolder"]:
print(
f"🎞️ 《{item['Name']}》匹配到Emby媒体库ID{item['Id']}"
f"🎞️ 《{item['Name']}》匹配到 Emby 媒体库 ID: {item['Id']}"
)
return item["Id"]
else:
print(f"🎞️ 搜索Emby媒体库{response.text}")
print(f"🎞️ 搜索 Emby 媒体库: {response.text}")
except Exception as e:
print(f"搜索 Emby 媒体库出错: {e}")
return ""

View File

@ -46,7 +46,7 @@ class Plex:
)
return True
else:
print(f"Plex媒体库: 连接失败❌ 状态码:{response.status_code}")
print(f"Plex 媒体库: 连接失败 ❌ 状态码: {response.status_code}")
except Exception as e:
print(f"获取 Plex 媒体库信息出错: {e}")
return False
@ -67,14 +67,14 @@ class Plex:
refresh_response = requests.get(refresh_url, headers=headers)
if refresh_response.status_code == 200:
print(
f"🎞️ 刷新Plex媒体库{library['title']} [{folder_path}] 成功"
f"🎞️ 刷新 Plex 媒体库: {library['title']} [{folder_path}] 成功 "
)
return True
else:
print(
f"🎞️ 刷新Plex媒体库刷新请求失败❌ 状态码:{refresh_response.status_code}"
f"🎞️ 刷新 Plex 媒体库: 刷新请求失败 ❌ 状态码: {refresh_response.status_code}"
)
print(f"🎞️ 刷新Plex媒体库{folder_path} 未找到匹配的媒体库")
print(f"🎞️ 刷新 Plex 媒体库: {folder_path} 未找到匹配的媒体库 ")
except Exception as e:
print(f"刷新 Plex 媒体库出错: {e}")
return False
@ -89,7 +89,7 @@ class Plex:
libraries = response.json()["MediaContainer"].get("Directory", [])
return libraries
else:
print(f"🎞️ 获取Plex媒体库信息失败❌ 状态码:{response.status_code}")
print(f"🎞️ 获取 Plex 媒体库信息失败 ❌ 状态码: {response.status_code}")
except Exception as e:
print(f"获取 Plex 媒体库信息出错: {e}")
return []

View File

@ -1048,9 +1048,10 @@ class Quark:
dir_paths_exist_arr.append(
{"file_path": dir_path, "fid": new_dir["fid"]}
)
print(f"创建文件夹:{dir_path}")
# print(f"创建文件夹:{dir_path}")
else:
print(f"创建文件夹:{dir_path} 失败, {mkdir_return['message']}")
# print(f"创建文件夹:{dir_path} 失败, {mkdir_return['message']}")
pass
# 储存目标目录的fid
for dir_path in dir_paths_exist_arr:
self.savepath_fid[dir_path["file_path"]] = dir_path["fid"]