pause torrents that have sufficient seeds

This commit is contained in:
AJ
2022-02-09 08:16:09 -05:00
parent 2cbf047271
commit fe019d6fb7

View File

@@ -1,4 +1,5 @@
import qbittorrentapi
import time
# instantiate a Client using the appropriate WebUI configuration
qbt_client = qbittorrentapi.Client(
@@ -8,6 +9,9 @@ qbt_client = qbittorrentapi.Client(
password='adminadmin',
)
max_seeds = 25
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.
@@ -21,14 +25,21 @@ 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
def dostuff():
for torrent in qbt_client.torrents.info.all():
if torrent.state_enum.is_downloading:
continue
if torrent.num_complete < max_seeds:
torrent.uploadLimit = 0
if torrent.num_complete > max_seeds:
torrent.pause()
else:
torrent.uploadLimit = 10240
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()