Use qbittorrentapi

This commit is contained in:
Jeffrey Serio 2024-11-05 17:56:46 -06:00
parent 70740ba949
commit 77b86fddae
2 changed files with 5 additions and 30 deletions

View File

@ -17,15 +17,6 @@ Options:
import qbittorrentapi import qbittorrentapi
from docopt import docopt 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 # convert byte units
@ -51,31 +42,15 @@ def human_bytes(input_bytes: int) -> str:
return "" 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(): def print_ssv():
with qbittorrentapi.Client( with qbittorrentapi.Client(
host="localhost", port=8080, username="", password="" host="localhost", port=8080, username="", password=""
) as qbt_client: ) as qbt_client:
try:
qbt_client.auth_log_in()
except qbittorrentapi.LoginFailed as e:
print(e)
sorted_torrents = sorted( sorted_torrents = sorted(
qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True
) )