Compare commits

...

5 Commits

Author SHA1 Message Date
AJ
80027a660f Removed test case 2022-09-15 21:50:55 -04:00
AJ
2c720e1bc5 Resume paused torrents 2022-07-06 07:30:57 -04:00
AJ
d8e7086d35 Limit seeding by changing ratio.
This way all torrents have a minimum seed ratio of 2.0
2022-05-03 17:43:49 -04:00
AJ
3f94364416 log start and end times 2022-02-09 08:23:31 -05:00
AJ
fe019d6fb7 pause torrents that have sufficient seeds 2022-02-09 08:16:09 -05:00

View File

@@ -1,4 +1,6 @@
import qbittorrentapi import qbittorrentapi
import time
import datetime
# instantiate a Client using the appropriate WebUI configuration # instantiate a Client using the appropriate WebUI configuration
qbt_client = qbittorrentapi.Client( qbt_client = qbittorrentapi.Client(
@@ -8,27 +10,43 @@ qbt_client = qbittorrentapi.Client(
password='adminadmin', password='adminadmin',
) )
# the Client will automatically acquire/maintain a logged-in state unlimited_seed_threshold = 25
# in line with any request. therefore, this is not strictly necessary;
# however, you may want to test the provided login credentials. def login():
try: try:
qbt_client.auth_log_in() qbt_client.auth_log_in()
except qbittorrentapi.LoginFailed as e: except qbittorrentapi.LoginFailed as e:
print(e) print(e)
# display qBittorrent info print(f'qBittorrent: {qbt_client.app.version}')
print(f'qBittorrent: {qbt_client.app.version}') print(f'qBittorrent Web API: {qbt_client.app.web_api_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 def set_ratio_limits():
for torrent in qbt_client.torrents.info.all():
# retrieve and show all torrents
for torrent in qbt_client.torrents.info.all():
if torrent.state_enum.is_downloading: if torrent.state_enum.is_downloading:
continue continue
if torrent.num_complete < max_seeds: # ratio_limit
torrent.uploadLimit = 0 # -2 = use the global value
# -1 = no limit
if torrent.num_complete > unlimited_seed_threshold:
if torrent.ratio_limit != -2:
torrent.set_share_limits(ratio_limit=-2, seeding_time_limit=-2)
log(f'{torrent.name}: set ratio limit to global limit')
else: else:
torrent.uploadLimit = 10240 if torrent.ratio_limit != -1 or 'paused' in torrent.state:
torrent.set_share_limits(ratio_limit=-1, seeding_time_limit=-2)
torrent.resume()
log(f'{torrent.name}: removed seed limit')
logfile = open(r"log.txt", "a")
def log(msg):
logfile.write(f'[{datetime.datetime.now()}] {msg}\n')
logfile.flush()
print(msg)
login()
set_ratio_limits()