mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
refactor(qbittorrent): convert static methods to instance methods for better encapsulation
This commit is contained in:
@@ -58,11 +58,10 @@ class Qbittorrent:
|
|||||||
pass
|
pass
|
||||||
return getattr(data, key, None)
|
return getattr(data, key, None)
|
||||||
|
|
||||||
@staticmethod
|
def __normalize_cookie(self, cookie: Any) -> dict:
|
||||||
def __normalize_cookie(cookie: Any) -> dict:
|
|
||||||
result = {}
|
result = {}
|
||||||
for key in ("domain", "path", "name", "value", "expirationDate"):
|
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, ""):
|
if value not in (None, ""):
|
||||||
result[key] = value
|
result[key] = value
|
||||||
return result
|
return result
|
||||||
@@ -94,16 +93,15 @@ class Qbittorrent:
|
|||||||
for morsel in raw_cookies.values()
|
for morsel in raw_cookies.values()
|
||||||
]
|
]
|
||||||
|
|
||||||
@staticmethod
|
def __parse_add_torrent_response(self, response: Any) -> Tuple[bool, List[str]]:
|
||||||
def __parse_add_torrent_response(response: Any) -> Tuple[bool, List[str]]:
|
|
||||||
if not response:
|
if not response:
|
||||||
return False, []
|
return False, []
|
||||||
if isinstance(response, str):
|
if isinstance(response, str):
|
||||||
return "Ok" in response, []
|
return "Ok" in response, []
|
||||||
|
|
||||||
success_count = Qbittorrent.__get_mapping_value(response, "success_count") or 0
|
success_count = self.__get_mapping_value(response, "success_count") or 0
|
||||||
pending_count = Qbittorrent.__get_mapping_value(response, "pending_count") or 0
|
pending_count = self.__get_mapping_value(response, "pending_count") or 0
|
||||||
added_torrent_ids = Qbittorrent.__get_mapping_value(response, "added_torrent_ids") or []
|
added_torrent_ids = self.__get_mapping_value(response, "added_torrent_ids") or []
|
||||||
if not isinstance(added_torrent_ids, list):
|
if not isinstance(added_torrent_ids, list):
|
||||||
added_torrent_ids = list(added_torrent_ids)
|
added_torrent_ids = list(added_torrent_ids)
|
||||||
added_torrent_ids = [str(torrent_id) for torrent_id in added_torrent_ids if torrent_id]
|
added_torrent_ids = [str(torrent_id) for torrent_id in added_torrent_ids if torrent_id]
|
||||||
|
|||||||
Reference in New Issue
Block a user