diff --git a/app/helper/plugin.py b/app/helper/plugin.py index c24cce70..6a8e19b9 100644 --- a/app/helper/plugin.py +++ b/app/helper/plugin.py @@ -146,7 +146,7 @@ class PluginHelper(metaclass=WeakSingleton): if not settings.PLUGIN_STATISTIC_SHARE: return {} res = RequestUtils(proxies=settings.PROXY, timeout=10).get_res(self._install_statistic) - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return res.json() return {} @@ -167,7 +167,7 @@ class PluginHelper(metaclass=WeakSingleton): "plugin_id": pid, "repo_url": repo_url }) - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return True return False @@ -192,7 +192,7 @@ class PluginHelper(metaclass=WeakSingleton): content_type="application/json", timeout=5).post(self._install_report, json={"plugins": payload_plugins}) - return True if res else False + return bool(res is not None and res.status_code == 200) def install(self, pid: str, repo_url: str, package_version: Optional[str] = None, force_install: bool = False) \ -> Tuple[bool, str]: @@ -1002,7 +1002,7 @@ class PluginHelper(metaclass=WeakSingleton): if not settings.PLUGIN_STATISTIC_SHARE: return {} res = await AsyncRequestUtils(proxies=settings.PROXY, timeout=10).get_res(self._install_statistic) - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return res.json() return {} @@ -1023,7 +1023,7 @@ class PluginHelper(metaclass=WeakSingleton): "plugin_id": pid, "repo_url": repo_url }) - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return True return False @@ -1048,7 +1048,7 @@ class PluginHelper(metaclass=WeakSingleton): content_type="application/json", timeout=5).post(self._install_report, json={"plugins": payload_plugins}) - return True if res else False + return bool(res is not None and res.status_code == 200) async def __async_get_file_list(self, pid: str, user_repo: str, package_version: Optional[str] = None) -> \ Tuple[Optional[list], Optional[str]]: diff --git a/app/helper/subscribe.py b/app/helper/subscribe.py index 6541172a..d8344838 100644 --- a/app/helper/subscribe.py +++ b/app/helper/subscribe.py @@ -108,7 +108,7 @@ class SubscribeHelper(metaclass=WeakSingleton): return False, "连接MoviePilot服务器失败" # 检查响应状态 - if res and res.status_code == 200: + if res.status_code == 200: # 清除缓存 if clear_cache: self.get_shares.cache_clear() @@ -126,7 +126,7 @@ class SubscribeHelper(metaclass=WeakSingleton): """ 处理返回List的HTTP响应 """ - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return res.json() return [] @@ -202,7 +202,7 @@ class SubscribeHelper(metaclass=WeakSingleton): res = RequestUtils(proxies=settings.PROXY, timeout=5, headers={ "Content-Type": "application/json" }).post_res(self._sub_reg, json=sub) - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return True return False @@ -216,7 +216,7 @@ class SubscribeHelper(metaclass=WeakSingleton): res = await AsyncRequestUtils(proxies=settings.PROXY, timeout=5, headers={ "Content-Type": "application/json" }).post_res(self._sub_reg, json=sub) - if res and res.status_code == 200: + if res is not None and res.status_code == 200: return True return False @@ -267,7 +267,7 @@ class SubscribeHelper(metaclass=WeakSingleton): sub.to_dict() for sub in subscribes ] }) - return True if res else False + return bool(res is not None and res.status_code == 200) def sub_share(self, subscribe_id: int, share_title: str, share_comment: str, share_user: str) -> Tuple[bool, str]: