From c180e5016469ecb3fbc019093bf608a5b96a25b6 Mon Sep 17 00:00:00 2001 From: jeblove <249972068@qq.com> Date: Thu, 28 Mar 2024 21:24:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0session=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E7=94=A8=E4=BA=8E=E8=8E=B7=E5=8F=96tr?= =?UTF-8?q?=E7=9A=84=E4=BC=9A=E8=AF=9D=E3=80=81=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/transmission/transmission.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/modules/transmission/transmission.py b/app/modules/transmission/transmission.py index 5fdb1f90..0e566cce 100644 --- a/app/modules/transmission/transmission.py +++ b/app/modules/transmission/transmission.py @@ -1,4 +1,4 @@ -from typing import Optional, Union, Tuple, List +from typing import Optional, Union, Tuple, List, Dict import transmission_rpc from transmission_rpc import Client, Torrent, File @@ -18,7 +18,7 @@ class Transmission: trc: Optional[Client] = None # 参考transmission web,仅查询需要的参数,加速种子搜索 - _trarg = ["id", "name", "status", "labels", "hashString", "totalSize", "percentDone", "addedDate", "trackerStats", + _trarg = ["id", "name", "status", "labels", "hashString", "totalSize", "percentDone", "addedDate", "trackerList", "trackerStats", "leftUntilDone", "rateDownload", "rateUpload", "recheckProgress", "rateDownload", "rateUpload", "peersGettingFromUs", "peersSendingToUs", "uploadRatio", "uploadedEver", "downloadedEver", "downloadDir", "error", "errorString", "doneDate", "queuePosition", "activityDate", "trackers"] @@ -395,3 +395,16 @@ class Transmission: except Exception as err: logger.error(f"修改tracker出错:{str(err)}") return False + + def get_session(self) -> Dict[str, Union[int, bool, str]]: + """ + 获取Transmission当前的会话信息和配置设置 + :return dict or False + """ + if not self.trc: + return False + try: + return self.trc.get_session() + except Exception as err: + logger.error(f"获取session出错:{str(err)}") + return False \ No newline at end of file