Limit seeding by changing ratio.
This way all torrents have a minimum seed ratio of 2.0
This commit is contained in:
@@ -10,46 +10,44 @@ qbt_client = qbittorrentapi.Client(
|
|||||||
password='adminadmin',
|
password='adminadmin',
|
||||||
)
|
)
|
||||||
|
|
||||||
max_seeds = 25
|
unlimited_seed_threshold = 25
|
||||||
|
|
||||||
def login():
|
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:
|
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}')
|
|
||||||
|
|
||||||
def dostuff():
|
def set_ratio_limits():
|
||||||
for torrent in qbt_client.torrents.info.all():
|
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:
|
# -2 = use the global value
|
||||||
torrent.pause()
|
# -1 = no limit
|
||||||
else:
|
x = -2
|
||||||
|
|
||||||
|
if torrent.num_complete <= unlimited_seed_threshold:
|
||||||
|
x = -1
|
||||||
|
|
||||||
|
if x == torrent.ratio_limit:
|
||||||
|
continue
|
||||||
|
|
||||||
|
torrent.set_share_limits(ratio_limit=x, seeding_time_limit=-2)
|
||||||
torrent.resume()
|
torrent.resume()
|
||||||
|
|
||||||
def update_seed_count():
|
log(f'{torrent.name}: set ratio limit to \'{torrent.ratio_limit}\'')
|
||||||
qbt_client.torrents.resume.all()
|
|
||||||
print('Waiting 30 seconds for seeds to update...')
|
|
||||||
time.sleep(30)
|
|
||||||
|
|
||||||
logfile = open(r"log.txt", "a")
|
|
||||||
|
logfile = open(r"C:\Tools\qbittorrent\log.txt", "a")
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
logfile.write('[{}] {}\n'.format(datetime.datetime.now(), msg))
|
logfile.write(f'[{datetime.datetime.now()}] {msg}\n')
|
||||||
logfile.flush()
|
logfile.flush()
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
log("starting")
|
|
||||||
login()
|
login()
|
||||||
update_seed_count()
|
set_ratio_limits()
|
||||||
dostuff()
|
|
||||||
log("done")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user