Compare commits
5 Commits
2cbf047271
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 80027a660f | |||
| 2c720e1bc5 | |||
| d8e7086d35 | |||
| 3f94364416 | |||
| fe019d6fb7 |
@@ -1,4 +1,6 @@
|
||||
import qbittorrentapi
|
||||
import time
|
||||
import datetime
|
||||
|
||||
# instantiate a Client using the appropriate WebUI configuration
|
||||
qbt_client = qbittorrentapi.Client(
|
||||
@@ -8,27 +10,43 @@ 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.
|
||||
unlimited_seed_threshold = 25
|
||||
|
||||
def login():
|
||||
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
|
||||
def set_ratio_limits():
|
||||
for torrent in qbt_client.torrents.info.all():
|
||||
if torrent.state_enum.is_downloading:
|
||||
continue
|
||||
|
||||
if torrent.num_complete < max_seeds:
|
||||
torrent.uploadLimit = 0
|
||||
# ratio_limit
|
||||
# -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:
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user