From d326670461b7f5875d7f4cba8c6de613a7349add Mon Sep 17 00:00:00 2001 From: rm Date: Mon, 29 Jan 2024 00:19:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=80=E4=BA=9B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PT/pt_get_info.py | 5 +++++ PT/qbittorrent_opt.py | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 PT/pt_get_info.py diff --git a/PT/pt_get_info.py b/PT/pt_get_info.py new file mode 100644 index 0000000..5495805 --- /dev/null +++ b/PT/pt_get_info.py @@ -0,0 +1,5 @@ +''' +获取用户信息 +比如等级,魔力值, + +''' \ No newline at end of file diff --git a/PT/qbittorrent_opt.py b/PT/qbittorrent_opt.py index 7e29be1..98378bf 100644 --- a/PT/qbittorrent_opt.py +++ b/PT/qbittorrent_opt.py @@ -1,6 +1,7 @@ from datetime import datetime import qbittorrentapi + ''' 官方文档:https://qbittorrent-api.readthedocs.io/en/latest/introduction.html ''' @@ -25,18 +26,21 @@ print(f"qBittorrent Web API: {qbt_client.app_web_api_version()}") for k, v in qbt_client.app.build_info.items(): print(f"{k}: {v}") + # 从url下载种子 返回 "Ok." 成功 或者 "Fails."失败 # add_res = qbt_client.torrents_add(urls="https://www.pttime.org/download.php?id=63655&passkey=b282678479d8f2cb8de1a811a707483d&uid=91145") # print(add_res) # qbt_client.torrents_reannounce() - def format_stamp(timestamp): return datetime.utcfromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S") + def format_day(timestamp): days = timestamp // (24 * 3600) hours = (timestamp % (24 * 3600)) // 3600 return f"{days}天零{hours}小时" + + # 检索并显示所有种子 for torrent in qbt_client.torrents_info(): # 完成任务的时间 @@ -49,10 +53,13 @@ for torrent in qbt_client.torrents_info(): last_activity = format_stamp(torrent.last_activity) # 做种时间 seeding_time = format_day(torrent.seeding_time) - print(f"{torrent.hash[-6:]}: {torrent.name} ({torrent.state})") - print(f"任务添加时间:{added_on}, 成任务的时间:{seen_complete} - {completion_on}, 最后活动时间:{last_activity}, 做种时间:{seeding_time}") - - + # print(f"{torrent.hash[-6:]}: {torrent.name} ({torrent.state})") + # print(f"任务添加时间:{added_on}, 成任务的时间:{seen_complete} - {completion_on}, 最后活动时间:{last_activity}, 做种时间:{seeding_time}") + print(f"{torrent.progress}") + if torrent.progress == 0: + # 删除文件 + qbt_client.torrents_delete(delete_files=True, torrent_hashes=torrent.hash) +# qbt_client.torrents_remove_categories() # 结束与 qBittorrent 的会话 qbt_client.auth_log_out() @@ -106,4 +113,4 @@ qbt_client.auth_log_out() # up_limit:上传速度限制。 # uploaded:已上传文件大小。 # uploaded_session:当前会话中已上传的文件大小。 -# upspeed:当前上传速度。 \ No newline at end of file +# upspeed:当前上传速度。