mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Compare commits
No commits in common. "796de3bdffc47db1314edf81577a360a4b6a20e0" and "a85baaf7323fac8c6e73f1dc4f84719dce3a1d17" have entirely different histories.
796de3bdff
...
a85baaf732
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
python/.venv
|
.direnv
|
||||||
|
.venv
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
beautifulsoup4==4.12.3
|
|
||||||
docopt==0.6.2
|
|
||||||
pandas==2.2.3
|
|
||||||
qbittorrent==0.1.6
|
|
||||||
Requests==2.32.3
|
|
||||||
resend==2.4.0
|
|
||||||
rich==13.9.4
|
|
@ -1,30 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""seed_armbian_torrents.py
|
|
||||||
|
|
||||||
Description:
|
|
||||||
Armbian torrents seed script
|
|
||||||
|
|
||||||
This script will download Armbian torrent files and add them to a qBittorrent
|
|
||||||
instance. It's intended to be run under /etc/cron.weekly or used in a systemd
|
|
||||||
timer.
|
|
||||||
|
|
||||||
This is a Python implementation of https://docs.armbian.com/Community_Torrent/
|
|
||||||
for qBittorrent.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
seed_armbian_torrents.py (HOSTNAME) (USERNAME) (PASSWORD)
|
|
||||||
seed_armbian_torrents.py -h
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
seed_armbian_torrents.py "http://localhost:8080" "admin" "adminadmin"
|
|
||||||
seed_armbian_torrents.py "https://cat.seedhost.eu/lol/qbittorrent" "lol" "pw"
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-h, --help show this help message and exit.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
import qbittorrentapi
|
|
||||||
import requests
|
|
||||||
from docopt import docopt
|
|
@ -7,7 +7,7 @@ let new_head = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
/home/jas/.local/bin/uv run -q /home/jas/admin-scripts/list_torrents.py
|
uv run -q /home/jas/admin-scripts/list_torrents.py
|
||||||
| from ssv -m 2
|
| from ssv -m 2
|
||||||
| to html
|
| to html
|
||||||
| str replace ($old_head) ($new_head)
|
| str replace ($old_head) ($new_head)
|
63
seed_armbian_torrents.py
Executable file
63
seed_armbian_torrents.py
Executable file
@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""seed_armbian_torrents.py
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Armbian torrents seed script
|
||||||
|
|
||||||
|
This script will download Armbian torrent files and add them to a qBittorrent
|
||||||
|
instance. It's intended to be run under /etc/cron.weekly or used in a systemd
|
||||||
|
timer.
|
||||||
|
|
||||||
|
This is a Python implementation of https://docs.armbian.com/Community_Torrent/
|
||||||
|
for qBittorrent.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
seed_armbian_torrents.py (HOSTNAME) (USERNAME) (PASSWORD)
|
||||||
|
seed_armbian_torrents.py -h
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
seed_armbian_torrents.py "http://localhost:8080" "admin" "adminadmin"
|
||||||
|
seed_armbian_torrents.py "https://cat.seedhost.eu/lol/qbittorrent" "lol" "pw"
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help show this help message and exit.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from io import BytesIO
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
from zipfile import ZipFile
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from docopt import docopt
|
||||||
|
from qbittorrent import Client
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
args = docopt(__doc__)
|
||||||
|
|
||||||
|
# Initialize client and login
|
||||||
|
qb = Client(args["HOSTNAME"])
|
||||||
|
qb.login(username=args["USERNAME"], password=args["PASSWORD"])
|
||||||
|
|
||||||
|
with TemporaryDirectory() as tmp_dir:
|
||||||
|
req = requests.get(
|
||||||
|
"https://dl.armbian.com/torrent/all-torrents.zip",
|
||||||
|
stream=True,
|
||||||
|
timeout=60,
|
||||||
|
)
|
||||||
|
|
||||||
|
with ZipFile(BytesIO(req.content)) as zip_file:
|
||||||
|
zip_file.extractall(tmp_dir)
|
||||||
|
|
||||||
|
for torrent in qb.torrents():
|
||||||
|
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:
|
||||||
|
with open(os.path.join(tmp_dir, torrent_file), "rb") as tf:
|
||||||
|
qb.download_from_file(tf, category="distro")
|
||||||
|
print(
|
||||||
|
f"Added {os.path.basename(os.path.join(tmp_dir, torrent_file))}"
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user