规范插件的日志输出

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

@ -82,7 +82,7 @@ class Alist_strm_gen:
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-Strm生成: 获取挂载路径失败❌ {file_list.get('message')}")
print(f"Alist-Strm 生成: 获取挂载路径失败 {file_list.get('message')}")
return False, (None, None)
# 2. 检查是否数字,调用 Alist API 获取存储信息
elif re.match(r"^\d+$", storage_id):
@ -97,15 +97,15 @@ class Alist_strm_gen:
)
elif storage_info["driver"] == "QuarkTV":
print(
f"Alist-Strm生成: [QuarkTV]驱动⚠️ storage_id请手动填入 /Alist挂载路径:/Quark目录路径"
f"Alist-Strm 生成: [QuarkTV] 驱动 ⚠️ storage_id 请手动填入 /Alist挂载路径:/Quark目录路径"
)
else:
print(f"Alist-Strm生成: 不支持[{storage_info['driver']}]驱动 ❌")
print(f"Alist-Strm 生成: 不支持 [{storage_info['driver']}] 驱动 ❌")
else:
print(f"Alist-Strm生成: storage_id[{storage_id}]格式错误❌")
print(f"Alist-Strm 生成: storage_id [{storage_id}] 格式错误❌")
# 返回结果
if storage_mount_path and quark_root_dir:
print(f"Alist-Strm生成: [{storage_mount_path}:{quark_root_dir}]")
print(f"Alist-Strm 生成: [{storage_mount_path}:{quark_root_dir}]")
return True, (storage_mount_path, quark_root_dir)
else:
return False, (None, None)
@ -121,15 +121,15 @@ class Alist_strm_gen:
if data.get("code") == 200:
return data.get("data", [])
else:
print(f"Alist-Strm生成: 获取存储失败❌ {data.get('message')}")
print(f"Alist-Strm 生成: 获取存储失败 {data.get('message')}")
except Exception as e:
print(f"Alist-Strm生成: 获取存储出错 {e}")
print(f"Alist-Strm 生成: 获取存储出错 {e}")
return []
def check_dir(self, path):
data = self.get_file_list(path)
if data.get("code") != 200:
print(f"📺 Alist-Strm生成: 获取文件列表失败❌{data.get('message')}")
print(f"📺 Alist-Strm 生成: 获取文件列表失败 {data.get('message')}")
return
elif files := data.get("data", {}).get("content"):
for item in files:
@ -154,7 +154,7 @@ class Alist_strm_gen:
response.raise_for_status()
return response.json()
except Exception as e:
print(f"📺 Alist-Strm生成: 获取文件列表出错❌ {e}")
print(f"📺 Alist-Strm 生成: 获取文件列表出错 {e}")
return {}
def generate_strm(self, file_path):
@ -171,7 +171,7 @@ class Alist_strm_gen:
os.makedirs(os.path.dirname(strm_path))
with open(strm_path, "w", encoding="utf-8") as strm_file:
strm_file.write(f"{self.strm_server}{file_path}")
print(f"📺 生成STRM文件 {strm_path} 成功")
print(f"📺 生成 STRM 文件 {strm_path} 成功 ")
def get_root_folder_full_path(self, cookie, pdir_fid):
if pdir_fid == "0":
@ -203,5 +203,5 @@ class Alist_strm_gen:
path = f"{path}/{item['file_name']}"
return path
except Exception as e:
print(f"Alist-Strm生成: 获取Quark路径出错 {e}")
print(f"Alist-Strm 生成: 获取 Quark 路径出错 {e}")
return ""

View File

@ -174,7 +174,7 @@ class Aria2:
# print(f"📥 Aria2下载: {file_path} (已存在,跳过)")
continue
print(f"📥 Aria2下载: {file_path}")
print(f"📥 Aria2 下载: {file_path}")
# 确保目录存在
os.makedirs(os.path.dirname(local_path), exist_ok=True)
@ -194,7 +194,7 @@ class Aria2:
try:
self.add_uri(aria2_params)
except Exception as e:
print(f"📥 Aria2添加下载任务失败: {e}")
print(f"📥 Aria2 添加下载任务失败: {e}")
def _make_rpc_request(self, method, params=None):
"""发出 JSON-RPC 请求."""
@ -211,17 +211,17 @@ class Aria2:
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Aria2下载: 错误{e}")
print(f"Aria2 下载: 错误{e}")
return {}
def get_version(self):
"""检查与 Aria2 的连接."""
response = self._make_rpc_request("aria2.getVersion")
if response.get("result"):
print(f"Aria2下载: v{response['result']['version']}")
print(f"Aria2 下载: v{response['result']['version']}")
return True
else:
print(f"Aria2下载: 连接失败{response.get('error')}")
print(f"Aria2 下载: 连接失败{response.get('error')}")
return False
def add_uri(self, params=None):

View File

@ -48,13 +48,13 @@ class Emby:
if "application/json" in response.headers["Content-Type"]:
response = response.json()
print(
f"Emby媒体库: {response.get('ServerName','')} v{response.get('Version','')}"
f"Emby 媒体库: {response.get('ServerName','')} v{response.get('Version','')}"
)
return True
else:
print(f"Emby媒体库: 连接失败❌ {response.text}")
print(f"Emby 媒体库: 连接失败 {response.text}")
except Exception as e:
print(f"获取Emby媒体库信息出错: {e}")
print(f"获取 Emby 媒体库信息出错: {e}")
return False
def refresh(self, emby_id):
@ -74,12 +74,12 @@ 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}")
print(f"刷新 Emby 媒体库出错: {e}")
return False
def search(self, media_name):
@ -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}")
print(f"搜索 Emby 媒体库出错: {e}")
return ""

View File

@ -42,13 +42,13 @@ class Plex:
if response.status_code == 200:
info = response.json()["MediaContainer"]
print(
f"Plex媒体库: {info.get('friendlyName','')} v{info.get('version','')}"
f"Plex 媒体库: {info.get('friendlyName','')} v{info.get('version','')}"
)
return True
else:
print(f"Plex媒体库: 连接失败❌ 状态码:{response.status_code}")
print(f"Plex 媒体库: 连接失败 ❌ 状态码: {response.status_code}")
except Exception as e:
print(f"获取Plex媒体库信息出错: {e}")
print(f"获取 Plex 媒体库信息出错: {e}")
return False
def refresh(self, folder_path):
@ -67,16 +67,16 @@ 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}")
print(f"刷新 Plex 媒体库出错: {e}")
return False
def _get_libraries(self):
@ -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}")
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"]