From 6861dada76befbf0d9b587f3ee1b3e0caecd819b Mon Sep 17 00:00:00 2001 From: Jeffrey Serio <23226432+hyperreal64@users.noreply.github.com> Date: Sun, 21 Jul 2024 09:55:52 -0500 Subject: [PATCH] Add seed-scihub-torrents --- bin/seed-scihub-torrents | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 bin/seed-scihub-torrents diff --git a/bin/seed-scihub-torrents b/bin/seed-scihub-torrents new file mode 100755 index 0000000..f8fb762 --- /dev/null +++ b/bin/seed-scihub-torrents @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +"""seed_scihub_torrents + +Usage: + seed_scihub_torrents (HOSTNAME) (USERNAME) (PASSWORD) (MAX_SEEDERS) + seed_scihub_torrents -h + +Examples: + seed_scihub_torrents "http://localhost:8080" "admin" "adminadmin" 4 + seed_scihub_torrents "https://cat.seedhost.eu/lol/qbittorrent" "lol" "pw" 8 + +Options: + -h, --help show this help message and exit +""" + +import json +import os + +import requests +from docopt import docopt +from qbittorrent import Client + + +if __name__ == "__main__": + args = docopt(__doc__) + qb = Client(args["HOSTNAME"]) + qb.login(username=args["USERNAME"], password=args["PASSWORD"]) + + TORRENT_HEALTH_URL = ( + "https://zrthstr.github.io/libgen_torrent_cardiography/torrent.json" + ) + response = requests.get(TORRENT_HEALTH_URL, timeout=60) + json_data = json.loads(response.text) + + for item in json_data: + if item["seeders"] <= int(args["MAX_SEEDERS"]): + qb.download_from_link(item["link"], category="scihub") + print(f"Added {os.path.basename(item["name"])}")