mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Use instance credentials for qbth
This commit is contained in:
parent
96fa139812
commit
e800652393
@ -4,7 +4,7 @@ These are scripts I use to automate various tasks in my homelab.
|
||||
|
||||
** bin
|
||||
- ~add_scihub_torrents~ : This script uses [[https://github.com/charmbracelet/gum][gum]] to select paginated text files that contain URLs of Sci Hub torrent files. For each selected file, the URLs are read and added to a qBittorrent instance.
|
||||
- ~qbth~ : This is a helper program for adding Linux and BSD distros to a qBittorrent instance.
|
||||
- ~qbth~ : This is a helper program for adding Linux and BSD distros to a qBittorrent instance. It's a bit crude, and the Python linter yells at me for it, but it gets the job done, and that's all I need it to do. Thank you.
|
||||
- ~qbt_sum_size~ : This script prints the total size of completed torrents and the total size of all torrents added to a qBittorrent instance. The former is a subset of the latter.
|
||||
- ~seed_armbian_torrents~ : This script downloads an archive from Armbian, extracts the torrent files within to a temporary directory, and adds each file to a qBittorrent instance. It first removes older Armbian torrents from the qBittorrent instance.
|
||||
- ~seed_scihub_torrents~ : This script 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.
|
||||
@ -14,3 +14,6 @@ These are scripts I use to automate various tasks in my homelab.
|
||||
*** system
|
||||
- ~server0-backup.service~ : A systemd service unit that runs the ~server0-backup~ script.
|
||||
- ~server0-backup.timer~ : A systemd timer unit that triggers the corresponding service unit.
|
||||
*** user
|
||||
- ~glances.service~ : A systemd service unit for the user scope that runs a glances server.
|
||||
- ~gmcapsuled.service~ : A systemd service unit for the user scope that runs the gmcapsuled Gemini server.
|
||||
|
28
bin/qbth
28
bin/qbth
@ -1,25 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""qbth - qbittorrent helper
|
||||
|
||||
Usage:
|
||||
qbth (HOSTNAME) (USERNAME) (PASSWORD)
|
||||
qbth -h
|
||||
|
||||
Examples:
|
||||
qbth "http://localhost:8080" "admin" "adminadmin"
|
||||
qbth "https://cat.seedhost.eu/lol/qbittorrent" "lol" "meow"
|
||||
|
||||
Options:
|
||||
-h, --help show this help message and exit
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from docopt import docopt
|
||||
from qbittorrent import Client
|
||||
|
||||
qb = Client("http://localhost:8080/")
|
||||
qb.login()
|
||||
args = docopt(__doc__)
|
||||
qb = Client(args["HOSTNAME"])
|
||||
qb.login(username=args["USERNAME"], password=args["PASSWORD"])
|
||||
|
||||
|
||||
def add_torrents(urls):
|
||||
def add_torrents(urls: list[str]):
|
||||
for url in urls:
|
||||
qb.download_from_link(url, category="distro")
|
||||
print(f"Added {os.path.basename(url)}")
|
||||
|
||||
|
||||
def add_torrents_from_html(webpage_url: str, torrent_substring: str):
|
||||
reqs = requests.get(webpage_url)
|
||||
reqs = requests.get(webpage_url, timeout=60)
|
||||
soup = BeautifulSoup(reqs.text, "html.parser")
|
||||
for link in soup.find_all("a"):
|
||||
if torrent_substring in link.get("href"):
|
||||
@ -96,7 +112,7 @@ def remove_fedora(relver: str):
|
||||
|
||||
def add_freebsd(relver: str):
|
||||
url = f"https://people.freebsd.org/~jmg/FreeBSD-{relver}-R-magnet.txt"
|
||||
reqs = requests.get(url)
|
||||
reqs = requests.get(url, timeout=60)
|
||||
data = reqs.text.split("\n")
|
||||
|
||||
for line in data:
|
||||
@ -131,7 +147,7 @@ def remove_netbsd(relver: str):
|
||||
|
||||
def add_nixos():
|
||||
url = "https://api.github.com/repos/AnimMouse/NixOS-ISO-Torrents/releases/latest"
|
||||
reqs = requests.get(url)
|
||||
reqs = requests.get(url, timeout=60)
|
||||
json_data = json.loads(reqs.text)
|
||||
for item in json_data["assets"]:
|
||||
qb.download_from_link(item["browser_download_url"], category="distro")
|
||||
|
Loading…
Reference in New Issue
Block a user