From 77b86fddae952e3334828a321d472e95bb74cc94 Mon Sep 17 00:00:00 2001 From: Jeffrey Serio Date: Tue, 5 Nov 2024 17:56:46 -0600 Subject: [PATCH] Use qbittorrentapi --- mastodon.py => .archived/mastodon.py | 0 list_torrents.py | 35 ++++------------------------ 2 files changed, 5 insertions(+), 30 deletions(-) rename mastodon.py => .archived/mastodon.py (100%) diff --git a/mastodon.py b/.archived/mastodon.py similarity index 100% rename from mastodon.py rename to .archived/mastodon.py diff --git a/list_torrents.py b/list_torrents.py index 96870e5..9d8e0f8 100755 --- a/list_torrents.py +++ b/list_torrents.py @@ -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 )