From fe019d6fb773f6ab667ae08c63da995795d8ce5c Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 9 Feb 2022 08:16:09 -0500 Subject: [PATCH] pause torrents that have sufficient seeds --- start-seeding.py | 53 +++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/start-seeding.py b/start-seeding.py index 5750a91..da85e96 100644 --- a/start-seeding.py +++ b/start-seeding.py @@ -1,4 +1,5 @@ import qbittorrentapi +import time # instantiate a Client using the appropriate WebUI configuration qbt_client = qbittorrentapi.Client( @@ -8,27 +9,37 @@ qbt_client = qbittorrentapi.Client( password='adminadmin', ) -# the Client will automatically acquire/maintain a logged-in state -# in line with any request. therefore, this is not strictly necessary; -# however, you may want to test the provided login credentials. -try: - qbt_client.auth_log_in() -except qbittorrentapi.LoginFailed as e: - print(e) - -# display qBittorrent info -print(f'qBittorrent: {qbt_client.app.version}') -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}') - max_seeds = 25 -# retrieve and show all torrents -for torrent in qbt_client.torrents.info.all(): - if torrent.state_enum.is_downloading: - continue +def login(): + # the Client will automatically acquire/maintain a logged-in state + # in line with any request. therefore, this is not strictly necessary; + # however, you may want to test the provided login credentials. + try: + qbt_client.auth_log_in() + except qbittorrentapi.LoginFailed as e: + print(e) - if torrent.num_complete < max_seeds: - torrent.uploadLimit = 0 - else: - torrent.uploadLimit = 10240 \ No newline at end of file + # display qBittorrent info + print(f'qBittorrent: {qbt_client.app.version}') + 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}') + +def dostuff(): + for torrent in qbt_client.torrents.info.all(): + if torrent.state_enum.is_downloading: + continue + + if torrent.num_complete > max_seeds: + torrent.pause() + else: + torrent.resume() + +def update_seed_count(): + qbt_client.torrents.resume.all() + print('Waiting 30 seconds for seeds to update...') + time.sleep(30) + +login() +update_seed_count() +dostuff() \ No newline at end of file