From 60cb9ba152ff092727ce8fbbc54ba0d3bcb3f667 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Wed, 27 Nov 2024 20:21:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=87=BD=E6=95=B0=E9=94=99=E8=AF=AF/?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 提高代码一致性和可读性,避免返回错误类型 --- plugins/alist.py | 6 +++--- plugins/alist_strm.py | 4 ++-- plugins/aria2.py | 4 ++-- plugins/emby.py | 4 ++-- plugins/plex.py | 3 +-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/alist.py b/plugins/alist.py index 9433cfc..b66beae 100644 --- a/plugins/alist.py +++ b/plugins/alist.py @@ -110,7 +110,7 @@ class Alist: print(f"Alist刷新: 存储{storage_id}连接失败❌ {data.get('message')}") except requests.exceptions.RequestException as e: print(f"Alist刷新: 获取Alist存储出错 {e}") - return False + return [] def refresh(self, path): data = self.get_file_list(path, True) @@ -146,7 +146,7 @@ class Alist: return response.json() except Exception as e: print(f"📁 Alist刷新: 获取文件列表出错❌ {e}") - return False + return {} def get_root_folder_full_path(self, cookie, pdir_fid): if pdir_fid == "0": @@ -179,4 +179,4 @@ class Alist: return "/".join(file_names) except requests.exceptions.RequestException as e: print(f"Alist刷新: 获取Quark路径出错 {e}") - return False + return "" diff --git a/plugins/alist_strm.py b/plugins/alist_strm.py index 312ab5a..2e56e0a 100644 --- a/plugins/alist_strm.py +++ b/plugins/alist_strm.py @@ -61,8 +61,8 @@ class Alist_strm: try: selected_configs = [int(x.strip()) for x in selected_configs_str.split(",")] except ValueError: - print("Error: 运行alist-strm配置错误,id应以,分割") - return None + print("🔗 alist-strm配置运行: 出错❌ id应以,分割") + return False data = [("selected_configs", config_id) for config_id in selected_configs] data.append(("action", "run_selected")) try: diff --git a/plugins/aria2.py b/plugins/aria2.py index e1774bb..1b49cb6 100644 --- a/plugins/aria2.py +++ b/plugins/aria2.py @@ -76,7 +76,7 @@ class Aria2: return response.json() except requests.exceptions.RequestException as e: print(f"Aria2下载: 错误{e}") - return None + return {} def get_version(self): """检查与 Aria2 的连接.""" @@ -91,4 +91,4 @@ class Aria2: def add_uri(self, params=None): """添加 URI 下载任务.""" response = self._make_rpc_request("aria2.addUri", params) - return response.get("result") if response else None + return response.get("result") if response else {} diff --git a/plugins/emby.py b/plugins/emby.py index 740eeb1..1223d02 100644 --- a/plugins/emby.py +++ b/plugins/emby.py @@ -84,7 +84,7 @@ class Emby: def search(self, media_name): if not media_name: - return False + return "" url = f"{self.url}/emby/Items" headers = {"X-Emby-Token": self.token} querystring = { @@ -113,4 +113,4 @@ class Emby: print(f"🎞️ 搜索Emby媒体库:{response.text}❌") except requests.exceptions.RequestException as e: print(f"搜索Emby媒体库出错: {e}") - return False + return "" diff --git a/plugins/plex.py b/plugins/plex.py index 27255a0..0bde1c1 100644 --- a/plugins/plex.py +++ b/plugins/plex.py @@ -90,7 +90,6 @@ class Plex: return libraries else: print(f"🎞️ 获取Plex媒体库信息失败❌ 状态码:{response.status_code}") - return None except Exception as e: print(f"获取Plex媒体库信息出错: {e}") - return None + return []