mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Use qbittorrentapi
This commit is contained in:
parent
70740ba949
commit
77b86fddae
@ -17,15 +17,6 @@ Options:
|
||||
|
||||
import qbittorrentapi
|
||||
from docopt import docopt
|
||||
from tabulate import tabulate
|
||||
|
||||
try:
|
||||
with qbittorrentapi.Client(
|
||||
host="localhost", port=8080, username="", password=""
|
||||
) as qbt_client:
|
||||
qbt_client.auth_log_in()
|
||||
except qbittorrentapi.LoginFailed as e:
|
||||
print(e)
|
||||
|
||||
|
||||
# convert byte units
|
||||
@ -51,31 +42,15 @@ def human_bytes(input_bytes: int) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def print_table():
|
||||
table = []
|
||||
headers = ["Name", "Total Size", "Trackers Count", "Ratio", "Uploaded"]
|
||||
with qbittorrentapi.Client(
|
||||
host="localhost", port=8080, username="", password=""
|
||||
) as qbt_client:
|
||||
sorted_torrents = sorted(
|
||||
qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True
|
||||
)
|
||||
for torrent in sorted_torrents:
|
||||
row = []
|
||||
row.append(torrent.name)
|
||||
row.append(human_bytes(torrent.total_size))
|
||||
row.append(torrent.trackers_count)
|
||||
row.append(torrent.ratio)
|
||||
row.append(human_bytes(torrent.uploaded))
|
||||
table.append(row)
|
||||
|
||||
print(tabulate(table, headers, tablefmt="grid"))
|
||||
|
||||
|
||||
def print_ssv():
|
||||
with qbittorrentapi.Client(
|
||||
host="localhost", port=8080, username="", password=""
|
||||
) as qbt_client:
|
||||
try:
|
||||
qbt_client.auth_log_in()
|
||||
except qbittorrentapi.LoginFailed as e:
|
||||
print(e)
|
||||
|
||||
sorted_torrents = sorted(
|
||||
qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user