Compare commits

..

No commits in common. "c80c1887bbd93a7004ab508071506b13631ec58e" and "83e26f1428fccf526c2f287f37a54aa82228989a" have entirely different histories.

13 changed files with 63 additions and 78 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
layout python3

View File

@ -1,11 +1,4 @@
# /// script
# dependencies = [
# "requests",
# "bs4",
# "docopt",
# "rich",
# ]
# ///
#!/usr/bin/env python3
"""calculate_mirror_size.py

View File

@ -1,9 +1,4 @@
# /// script
# dependencies = [
# "requests",
# "docopt",
# ]
# ///
#!/usr/bin/env python3
"""fetch_combined_trackers_list.py

View File

@ -1,9 +1,4 @@
# /// script
# dependencies = [
# "requests",
# "docopt",
# ]
# ///
#!/usr/bin/env python3
"""fetch_scihub_infohashes.py

View File

@ -1,9 +1,4 @@
# /// script
# dependencies = [
# "qbittorrent-api",
# "docopt",
# ]
# ///
#!/home/jas/virtualenvs/list_torrents/bin/python3
"""list_torrents.py
@ -59,7 +54,6 @@ def print_ssv():
sorted_torrents = sorted(
qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True
)
print("Name Size # of Trackers Ratio Uploaded")
for torrent in sorted_torrents:
name = torrent.name
size = human_bytes(torrent.total_size)

View File

@ -2,12 +2,12 @@
let old_head = "<html><style>body { background-color:white;color:black; }</style><body>"
let new_head = (
["<html><head><title>Torrent Stats</title><link type="text/css" rel="stylesheet" href="https://files.hyperreal.coffee/css/style1.css"/></head><body><h4>Last updated:", (date now | format date "%F %T%:z"), "</h4>"]
["<html><head><title>Torrent Stats</title><link type="text/css" rel="stylesheet" href="https://files.hyperreal.coffee/css/main-style.css"/></head><body><h4>Last updated:", (date now | format date "%F %T%:z"), "</h4>"]
| str join ' '
)
(
uv run -q /home/jas/admin-scripts/list_torrents.py
/home/jas/admin-scripts/list_torrents.py
| from ssv -m 2
| to html
| str replace ($old_head) ($new_head)

View File

@ -1,9 +1,4 @@
# /// script
# dependencies = [
# "qbittorrent-api",
# "docopt",
# ]
# ///
#!/usr/bin/env python3
"""qbt_sum_size.py

View File

@ -1,11 +1,4 @@
# /// script
# dependencies = [
# "qbittorrent-api",
# "requests",
# "bs4",
# "docopt",
# ]
# ///
#!/usr/bin/env python3
"""qbth.py - qbittorrent helper

24
requirements.txt Normal file
View File

@ -0,0 +1,24 @@
attr==0.3.2
beautifulsoup4==4.12.3
colorama==0.4.6
ConfigParser==7.1.0
cryptography==43.0.3
docopt==0.6.2
docutils==0.21.2
filelock==3.16.1
HTMLParser==0.0.2
ipython==8.29.0
ipywidgets==8.1.5
jnius==1.1.0
keyring==25.5.0
pandas==2.2.3
Pillow==11.0.0
protobuf==5.28.3
pyOpenSSL==24.2.1
qbittorrent==0.1.6
redis==5.2.0
resend==2.4.0
Sphinx==8.1.3
thread==2.0.5
urllib3_secure_extra==0.1.0
xmlrpclib==1.0.1

View File

@ -1,10 +1,4 @@
# /// script
# dependencies = [
# "qbittorrent-api",
# "requests",
# "docopt",
# ]
# ///
#!/usr/bin/env python3
"""scihub_knapsack.py

View File

@ -1,8 +1,5 @@
# /// script
# dependencies = [
# "resend",
# ]
# ///
#!/usr/bin/env nix-shell
#! nix-shell -i python3 --packages python3 python312Packages.resend
import socket
import subprocess

View File

@ -1,9 +1,5 @@
# /// script
# dependencies = [
# "resend",
# ]
# ///
#!/usr/bin/env nix-shell
#! nix-shell -i python3 --packages python3 python312Packages.resend
import socket
import subprocess

View File

@ -1,10 +1,4 @@
# /// script
# dependencies = [
# "qbittorrent-api",
# "docopt",
# "rich",
# ]
# ///
#!/usr/bin/env python3
"""update_tracker.py
@ -78,23 +72,37 @@ if __name__ == "__main__":
# Create a NamedTemporaryFile and write all infohashes to it, one per line
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)
# Use `sudo cp -f` to copy the infohashes file to the torrent tracker's config
# directory, overwriting the whitelist.txt file.
# Use scp to copy the infohashes file to the torrent tracker's config
# directory on the remote torrent tracker server, overwriting the
# whitelist.txt file
console.log(
"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(
["sudo", "cp", "-f", ntf.name, "/etc/opentracker/whitelist.txt"]
[
"scp",
"-q",
ntf.name,
f"root@{tracker_domain}:/etc/opentracker/whitelist.txt",
]
)
# Run `sudo systemctl restart opentracker.service`
console.log("Restarting opentracker.service")
subprocess.run(["sudo", "systemctl", "restart", "opentracker.service"])
# Use SSH to run `systemctl restart opentracker.service` on the remote
# torrent tracker server
console.log("Restarting opentracker.service on the remote server.")
subprocess.run(
[
"ssh",
f"root@{tracker_domain}",
"systemctl",
"restart",
"opentracker.service",
]
)
# Reannounce all torrents in each qBittorrent instance to their trackers
console.log("Reannouncing all torrents to their trackers.")
@ -105,7 +113,7 @@ if __name__ == "__main__":
password=item["password"],
) as qbt_client:
for torrent in qbt_client.torrents_info():
torrent.reannounce()
torrent.reannounce(torrent.hash)
console.log("Done!")