diff --git a/bin/qbt_sum_size b/bin/qbt_sum_size index 50eb468..9de7c11 100755 --- a/bin/qbt_sum_size +++ b/bin/qbt_sum_size @@ -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)}") diff --git a/bin/qbth b/bin/qbth index 85df495..96d5e12 100755 --- a/bin/qbth +++ b/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): diff --git a/bin/seed_armbian_torrents b/bin/seed_armbian_torrents index 41bd9d6..a668c7e 100755 --- a/bin/seed_armbian_torrents +++ b/bin/seed_armbian_torrents @@ -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: