From 06197144c0abd4386dff0e6b705d05d6f0e17e3c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 7 May 2026 08:25:34 +0800 Subject: [PATCH] refactor(qbittorrent): convert static methods to instance methods for better encapsulation --- app/modules/qbittorrent/qbittorrent.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/modules/qbittorrent/qbittorrent.py b/app/modules/qbittorrent/qbittorrent.py index f61a7b743..efe24de69 100644 --- a/app/modules/qbittorrent/qbittorrent.py +++ b/app/modules/qbittorrent/qbittorrent.py @@ -58,11 +58,10 @@ class Qbittorrent: pass return getattr(data, key, None) - @staticmethod - def __normalize_cookie(cookie: Any) -> dict: + def __normalize_cookie(self, cookie: Any) -> dict: result = {} for key in ("domain", "path", "name", "value", "expirationDate"): - value = Qbittorrent.__get_mapping_value(cookie, key) + value = self.__get_mapping_value(cookie, key) if value not in (None, ""): result[key] = value return result @@ -94,16 +93,15 @@ class Qbittorrent: for morsel in raw_cookies.values() ] - @staticmethod - def __parse_add_torrent_response(response: Any) -> Tuple[bool, List[str]]: + def __parse_add_torrent_response(self, response: Any) -> Tuple[bool, List[str]]: if not response: return False, [] if isinstance(response, str): return "Ok" in response, [] - success_count = Qbittorrent.__get_mapping_value(response, "success_count") or 0 - pending_count = Qbittorrent.__get_mapping_value(response, "pending_count") or 0 - added_torrent_ids = Qbittorrent.__get_mapping_value(response, "added_torrent_ids") or [] + success_count = self.__get_mapping_value(response, "success_count") or 0 + pending_count = self.__get_mapping_value(response, "pending_count") or 0 + added_torrent_ids = self.__get_mapping_value(response, "added_torrent_ids") or [] if not isinstance(added_torrent_ids, list): added_torrent_ids = list(added_torrent_ids) added_torrent_ids = [str(torrent_id) for torrent_id in added_torrent_ids if torrent_id]