diff --git a/README.org b/README.org index 2799e7a..cc8404e 100644 --- a/README.org +++ b/README.org @@ -18,5 +18,5 @@ These are scripts I use to automate various sysadmin tasks. - ~seed_scihub_max_seeders.py~ : Finds which torrents have less than or equal to N seeders, where N is an integer argument supplied by the user. It then adds these torrents to a qBittorrent instance. - ~update_tracker.py~ : Fetches infohashes of all torrents in each qBittorrent instance referenced in the config file, and updates my public torrent tracker's whitelist. #+BEGIN_EXPORT html - + #+END_EXPORT diff --git a/bin/update_tracker.py b/bin/update_tracker.py index 487bdbd..1cdaab1 100755 --- a/bin/update_tracker.py +++ b/bin/update_tracker.py @@ -44,7 +44,7 @@ if __name__ == "__main__": # Collect infohashes of all torrents in each qBittorrent instance console.log( - "Collecting infohashes of all torrents in each qBittorrent instance" + "Collecting infohashes of all torrents in each qBittorrent instance." ) torrent_infohashes = [] for item in auth_data["instances"]: @@ -55,11 +55,11 @@ if __name__ == "__main__": torrent_infohashes.append(torrent.get("hash")) # type: ignore # Format the infohashes to have a \n at the end - console.log("Formatting infohashes to have a newline at the end") + console.log("Formatting infohashes to have a newline at the end.") format_infohashes = set([f"{infohash}\n" for infohash in torrent_infohashes]) # Create a NamedTemporaryFile and write all infohashes to it, one per line - console.log("Creating temporary file to write infohashes to") + console.log("Creating temporary file to write infohashes to.") with tempfile.NamedTemporaryFile() as ntf: with open(ntf.name, "w") as tf: tf.writelines(format_infohashes) @@ -68,7 +68,7 @@ if __name__ == "__main__": # directory on the remote torrent tracker server, overwriting the # whitelist.txt file console.log( - "SSH-copying the temporary infohashes file to the torrent tracker's whitelist" + "SSH-copying the temporary infohashes file to the torrent tracker's whitelist." ) subprocess.run( [ @@ -81,7 +81,7 @@ if __name__ == "__main__": # Use SSH to run `systemctl restart opentracker.service` on the remote # torrent tracker server - console.log("Restarting opentracker.service on the remote server") + console.log("Restarting opentracker.service on the remote server.") subprocess.run( [ "ssh", @@ -96,7 +96,7 @@ if __name__ == "__main__": # tracker list. if args["--add-nirn-tracker"]: console.log( - "Ensuring bttracker.nirn.quest:6969/announce is added to each torrent's tracker list" + "Ensuring bttracker.nirn.quest:6969/announce is added to each torrent's tracker list." ) for item in auth_data["instances"]: qb = Client(item["hostname"]) @@ -108,16 +108,18 @@ if __name__ == "__main__": ) # Reannounce all torrents in each qBittorrent instance to their trackers - console.log("Reannouncing all torrents to their trackers") + console.log("Reannouncing all torrents to their trackers.") for item in auth_data["instances"]: qb = Client(item["hostname"]) qb.login(username=item["username"], password=item["password"]) torrent_infohashes = [torrent.get("hash") for torrent in qb.torrents()] # type: ignore qb.reannounce(torrent_infohashes) + console.log("Done!") + # Print output and make it look sexy ;) console = Console() - tasks = Text("Tasks completed:\n") + tasks = Text("\nTasks completed:\n") tasks.stylize("bold magenta") console.print(tasks) console.print(":white_check_mark: update the tracker's whitelist")