Check for availability of libgen.rs

This commit is contained in:
Jeffrey Serio 2024-08-25 00:20:36 -05:00
parent 426d8de0e3
commit 1b81d47b71
4 changed files with 19 additions and 4 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use nix

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.direnv

View File

@ -166,14 +166,22 @@ if __name__ == "__main__":
# If it's a dry run, only print the knapsack's contents. Otherwise,
# add the knapsack's contents to the qBittorrent instance.
# When finished, print the number of items and the combined weight of all
# items in the knapsack.
if args["--dry-run"]:
# items in the knapsack. Before attempting to add items to the qBittorrent
# instance, check to see if libgen.rs is even working. If libgen.rs is down
# no torrents can be added to the qBittorrent instance, so exit with an
# notice.
if dry_run:
for torrent in knapsack:
print(torrent["name"])
print(torrent["link"])
else:
response = requests.get("https://libgen.rs")
if not response.ok:
exit(
"It appears https://libgen.rs is currently down. Please try again later."
)
for torrent in knapsack:
qb.download_from_link(torrent["link"], category="scihub")
print(f"Added {torrent["name"]}")
print(f"Added {torrent['name']}")
print("----------------")
print(f"Count: {len(knapsack)} torrents")

View File

@ -22,10 +22,15 @@ in pkgs.python312.buildEnv.override rec {
extraLibs = [
pkgs.python312Packages.beautifulsoup4
pkgs.python312Packages.black
pkgs.python312Packages.bpython
pkgs.python312Packages.docopt
pkgs.python312Packages.isort
pkgs.python312Packages.nose
pkgs.python312Packages.pytest
pkgs.python312Packages.requests
pkgs.python312Packages.rich
pyright
python-qbittorrent
];
}