This commit is contained in:
Jeffrey Serio 2024-07-27 11:33:18 -05:00
parent eb0afeacf3
commit 0f07829f4d
3 changed files with 13 additions and 14 deletions

View File

@ -54,13 +54,13 @@ if __name__ == "__main__":
# get total_completed_bytes # get total_completed_bytes
completed_torrent_sizes = list() completed_torrent_sizes = list()
for torrent in torrents: for torrent in torrents:
if torrent["state"] == "queuedUP": if torrent.get("state") == "queuedUP": # type: ignore
completed_torrent_sizes.append(torrent["total_size"]) completed_torrent_sizes.append(torrent.get("total_size")) # type: ignore
total_completed_bytes = sum(completed_torrent_sizes) total_completed_bytes = sum(completed_torrent_sizes)
# get total_added_bytes # get total_added_bytes
total_added_bytes = sum([torrent["total_size"] for torrent in torrents]) total_added_bytes = sum([torrent.get("total_size") for torrent in torrents]) # type: ignore
# print the results # print the results
print(f"\nTotal completed size: {human_bytes(total_completed_bytes)}") print(f"\nTotal completed size: {human_bytes(total_completed_bytes)}")

View File

@ -69,11 +69,10 @@ def remove_torrents(distro_substring: str):
distro_substring: a string that is a substring of the distro distro_substring: a string that is a substring of the distro
torrent's file name. torrent's file name.
""" """
torrents = qb.torrents() for torrent in qb.torrents():
for torrent in torrents: if distro_substring in torrent.get("name") # type: ignore
if distro_substring in torrent["name"]: qb.delete_permanently(torrent.get("hash")) # type: ignore
qb.delete_permanently(torrent["hash"]) print(f"Removed {torrent.get('name')}") # type: ignore
print(f"Removed {torrent['name']}")
def add_almalinux(rel_ver: str): def add_almalinux(rel_ver: str):
@ -178,9 +177,9 @@ def remove_fedora(rel_ver: str):
""" """
torrents = qb.torrents() torrents = qb.torrents()
for torrent in torrents: for torrent in torrents:
if torrent["name"].startswith("Fedora") and torrent["name"].endswith(rel_ver): if torrent.get("name").startswith("Fedora") and torrent.get("name").endswith(rel_ver): # type: ignore
qb.delete_permanently(torrent["hash"]) qb.delete_permanently(torrent.get("hash")) # type: ignore
print(f"Removed {torrent['name']}") print(f"Removed {torrent.get('name')}") # type: ignore
def add_freebsd(rel_ver: str): def add_freebsd(rel_ver: str):

View File

@ -51,9 +51,9 @@ if __name__ == "__main__":
torrents = qb.torrents() torrents = qb.torrents()
for torrent in torrents: for torrent in torrents:
if "Armbian" in torrent["name"]: if "Armbian" in torrent.get("name"): # type: ignore
qb.delete_permanently(torrent["hash"]) qb.delete_permanently(torrent.get("hash")) # type: ignore
print(f"Removed {torrent['name']}") print(f"Removed {torrent.get('name')}") # type: ignore
torrent_files = os.listdir(tmp_dir) torrent_files = os.listdir(tmp_dir)
for torrent_file in torrent_files: for torrent_file in torrent_files: