mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 17:13:41 +01:00
Compare commits
No commits in common. "c80c1887bbd93a7004ab508071506b13631ec58e" and "83e26f1428fccf526c2f287f37a54aa82228989a" have entirely different histories.
c80c1887bb
...
83e26f1428
@ -1,11 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "requests",
|
|
||||||
# "bs4",
|
|
||||||
# "docopt",
|
|
||||||
# "rich",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""calculate_mirror_size.py
|
"""calculate_mirror_size.py
|
||||||
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "requests",
|
|
||||||
# "docopt",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""fetch_combined_trackers_list.py
|
"""fetch_combined_trackers_list.py
|
||||||
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "requests",
|
|
||||||
# "docopt",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""fetch_scihub_infohashes.py
|
"""fetch_scihub_infohashes.py
|
||||||
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
# /// script
|
#!/home/jas/virtualenvs/list_torrents/bin/python3
|
||||||
# dependencies = [
|
|
||||||
# "qbittorrent-api",
|
|
||||||
# "docopt",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""list_torrents.py
|
"""list_torrents.py
|
||||||
|
|
||||||
@ -59,7 +54,6 @@ def print_ssv():
|
|||||||
sorted_torrents = sorted(
|
sorted_torrents = sorted(
|
||||||
qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True
|
qbt_client.torrents_info(), key=lambda d: d.ratio, reverse=True
|
||||||
)
|
)
|
||||||
print("Name Size # of Trackers Ratio Uploaded")
|
|
||||||
for torrent in sorted_torrents:
|
for torrent in sorted_torrents:
|
||||||
name = torrent.name
|
name = torrent.name
|
||||||
size = human_bytes(torrent.total_size)
|
size = human_bytes(torrent.total_size)
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
let old_head = "<html><style>body { background-color:white;color:black; }</style><body>"
|
let old_head = "<html><style>body { background-color:white;color:black; }</style><body>"
|
||||||
let new_head = (
|
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 ' '
|
| str join ' '
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
uv run -q /home/jas/admin-scripts/list_torrents.py
|
/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)
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "qbittorrent-api",
|
|
||||||
# "docopt",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""qbt_sum_size.py
|
"""qbt_sum_size.py
|
||||||
|
|
||||||
|
9
qbth.py
9
qbth.py
@ -1,11 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "qbittorrent-api",
|
|
||||||
# "requests",
|
|
||||||
# "bs4",
|
|
||||||
# "docopt",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""qbth.py - qbittorrent helper
|
"""qbth.py - qbittorrent helper
|
||||||
|
|
||||||
|
24
requirements.txt
Normal file
24
requirements.txt
Normal 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
|
@ -1,10 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "qbittorrent-api",
|
|
||||||
# "requests",
|
|
||||||
# "docopt",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""scihub_knapsack.py
|
"""scihub_knapsack.py
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
# /// script
|
#!/usr/bin/env nix-shell
|
||||||
# dependencies = [
|
#! nix-shell -i python3 --packages python3 python312Packages.resend
|
||||||
# "resend",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
# /// script
|
#!/usr/bin/env nix-shell
|
||||||
# dependencies = [
|
#! nix-shell -i python3 --packages python3 python312Packages.resend
|
||||||
# "resend",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
# /// script
|
#!/usr/bin/env python3
|
||||||
# dependencies = [
|
|
||||||
# "qbittorrent-api",
|
|
||||||
# "docopt",
|
|
||||||
# "rich",
|
|
||||||
# ]
|
|
||||||
# ///
|
|
||||||
|
|
||||||
"""update_tracker.py
|
"""update_tracker.py
|
||||||
|
|
||||||
@ -78,23 +72,37 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Create a NamedTemporaryFile and write all infohashes to it, one per line
|
# Create a NamedTemporaryFile and write all infohashes to it, one per line
|
||||||
console.log("Creating temporary file to write infohashes to.")
|
console.log("Creating temporary file to write infohashes to.")
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile() as ntf:
|
with tempfile.NamedTemporaryFile() as ntf:
|
||||||
with open(ntf.name, "w") as tf:
|
with open(ntf.name, "w") as tf:
|
||||||
tf.writelines(format_infohashes)
|
tf.writelines(format_infohashes)
|
||||||
|
|
||||||
# Use `sudo cp -f` to copy the infohashes file to the torrent tracker's config
|
# Use scp to copy the infohashes file to the torrent tracker's config
|
||||||
# directory, overwriting the whitelist.txt file.
|
# directory on the remote torrent tracker server, overwriting the
|
||||||
|
# whitelist.txt file
|
||||||
console.log(
|
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(
|
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`
|
# Use SSH to run `systemctl restart opentracker.service` on the remote
|
||||||
console.log("Restarting opentracker.service")
|
# torrent tracker server
|
||||||
subprocess.run(["sudo", "systemctl", "restart", "opentracker.service"])
|
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
|
# Reannounce all torrents in each qBittorrent instance to their trackers
|
||||||
console.log("Reannouncing all torrents to their trackers.")
|
console.log("Reannouncing all torrents to their trackers.")
|
||||||
@ -105,7 +113,7 @@ if __name__ == "__main__":
|
|||||||
password=item["password"],
|
password=item["password"],
|
||||||
) as qbt_client:
|
) as qbt_client:
|
||||||
for torrent in qbt_client.torrents_info():
|
for torrent in qbt_client.torrents_info():
|
||||||
torrent.reannounce()
|
torrent.reannounce(torrent.hash)
|
||||||
|
|
||||||
console.log("Done!")
|
console.log("Done!")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user