mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Refactor
This commit is contained in:
parent
eb0afeacf3
commit
0f07829f4d
@ -54,13 +54,13 @@ if __name__ == "__main__":
|
||||
# get total_completed_bytes
|
||||
completed_torrent_sizes = list()
|
||||
for torrent in torrents:
|
||||
if torrent["state"] == "queuedUP":
|
||||
completed_torrent_sizes.append(torrent["total_size"])
|
||||
if torrent.get("state") == "queuedUP": # type: ignore
|
||||
completed_torrent_sizes.append(torrent.get("total_size")) # type: ignore
|
||||
|
||||
total_completed_bytes = sum(completed_torrent_sizes)
|
||||
|
||||
# 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(f"\nTotal completed size: {human_bytes(total_completed_bytes)}")
|
||||
|
15
bin/qbth
15
bin/qbth
@ -69,11 +69,10 @@ def remove_torrents(distro_substring: str):
|
||||
distro_substring: a string that is a substring of the distro
|
||||
torrent's file name.
|
||||
"""
|
||||
torrents = qb.torrents()
|
||||
for torrent in torrents:
|
||||
if distro_substring in torrent["name"]:
|
||||
qb.delete_permanently(torrent["hash"])
|
||||
print(f"Removed {torrent['name']}")
|
||||
for torrent in qb.torrents():
|
||||
if distro_substring in torrent.get("name") # type: ignore
|
||||
qb.delete_permanently(torrent.get("hash")) # type: ignore
|
||||
print(f"Removed {torrent.get('name')}") # type: ignore
|
||||
|
||||
|
||||
def add_almalinux(rel_ver: str):
|
||||
@ -178,9 +177,9 @@ def remove_fedora(rel_ver: str):
|
||||
"""
|
||||
torrents = qb.torrents()
|
||||
for torrent in torrents:
|
||||
if torrent["name"].startswith("Fedora") and torrent["name"].endswith(rel_ver):
|
||||
qb.delete_permanently(torrent["hash"])
|
||||
print(f"Removed {torrent['name']}")
|
||||
if torrent.get("name").startswith("Fedora") and torrent.get("name").endswith(rel_ver): # type: ignore
|
||||
qb.delete_permanently(torrent.get("hash")) # type: ignore
|
||||
print(f"Removed {torrent.get('name')}") # type: ignore
|
||||
|
||||
|
||||
def add_freebsd(rel_ver: str):
|
||||
|
@ -51,9 +51,9 @@ if __name__ == "__main__":
|
||||
|
||||
torrents = qb.torrents()
|
||||
for torrent in torrents:
|
||||
if "Armbian" in torrent["name"]:
|
||||
qb.delete_permanently(torrent["hash"])
|
||||
print(f"Removed {torrent['name']}")
|
||||
if "Armbian" in torrent.get("name"): # type: ignore
|
||||
qb.delete_permanently(torrent.get("hash")) # type: ignore
|
||||
print(f"Removed {torrent.get('name')}") # type: ignore
|
||||
|
||||
torrent_files = os.listdir(tmp_dir)
|
||||
for torrent_file in torrent_files:
|
||||
|
Loading…
Reference in New Issue
Block a user