mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-25 09:03:41 +01:00
Compare commits
7 Commits
83e26f1428
...
c80c1887bb
Author | SHA1 | Date | |
---|---|---|---|
c80c1887bb | |||
2498fc3b1d | |||
1fdb07e6c0 | |||
90db8fbda4 | |||
4c3e7e227d | |||
172bdfef48 | |||
3d10a07ab9 |
@ -1,4 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "requests",
|
||||||
|
# "bs4",
|
||||||
|
# "docopt",
|
||||||
|
# "rich",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""calculate_mirror_size.py
|
"""calculate_mirror_size.py
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "requests",
|
||||||
|
# "docopt",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""fetch_combined_trackers_list.py
|
"""fetch_combined_trackers_list.py
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "requests",
|
||||||
|
# "docopt",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""fetch_scihub_infohashes.py
|
"""fetch_scihub_infohashes.py
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#!/home/jas/virtualenvs/list_torrents/bin/python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "qbittorrent-api",
|
||||||
|
# "docopt",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""list_torrents.py
|
"""list_torrents.py
|
||||||
|
|
||||||
@ -54,6 +59,7 @@ 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/main-style.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/style1.css"/></head><body><h4>Last updated:", (date now | format date "%F %T%:z"), "</h4>"]
|
||||||
| str join ' '
|
| str join ' '
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
/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)
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "qbittorrent-api",
|
||||||
|
# "docopt",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""qbt_sum_size.py
|
"""qbt_sum_size.py
|
||||||
|
|
||||||
|
9
qbth.py
9
qbth.py
@ -1,4 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "qbittorrent-api",
|
||||||
|
# "requests",
|
||||||
|
# "bs4",
|
||||||
|
# "docopt",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""qbth.py - qbittorrent helper
|
"""qbth.py - qbittorrent helper
|
||||||
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
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,4 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "qbittorrent-api",
|
||||||
|
# "requests",
|
||||||
|
# "docopt",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""scihub_knapsack.py
|
"""scihub_knapsack.py
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env nix-shell
|
# /// script
|
||||||
#! nix-shell -i python3 --packages python3 python312Packages.resend
|
# dependencies = [
|
||||||
|
# "resend",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#!/usr/bin/env nix-shell
|
# /// script
|
||||||
#! nix-shell -i python3 --packages python3 python312Packages.resend
|
# dependencies = [
|
||||||
|
# "resend",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
# /// script
|
||||||
|
# dependencies = [
|
||||||
|
# "qbittorrent-api",
|
||||||
|
# "docopt",
|
||||||
|
# "rich",
|
||||||
|
# ]
|
||||||
|
# ///
|
||||||
|
|
||||||
"""update_tracker.py
|
"""update_tracker.py
|
||||||
|
|
||||||
@ -72,37 +78,23 @@ 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 scp to copy the infohashes file to the torrent tracker's config
|
# Use `sudo cp -f` to copy the infohashes file to the torrent tracker's config
|
||||||
# directory on the remote torrent tracker server, overwriting the
|
# directory, overwriting the whitelist.txt file.
|
||||||
# whitelist.txt file
|
|
||||||
console.log(
|
console.log(
|
||||||
"SSH-copying the temporary infohashes file to the torrent tracker's whitelist."
|
"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",
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Use SSH to run `systemctl restart opentracker.service` on the remote
|
# Run `sudo systemctl restart opentracker.service`
|
||||||
# torrent tracker server
|
console.log("Restarting opentracker.service")
|
||||||
console.log("Restarting opentracker.service on the remote server.")
|
subprocess.run(["sudo", "systemctl", "restart", "opentracker.service"])
|
||||||
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.")
|
||||||
@ -113,7 +105,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.hash)
|
torrent.reannounce()
|
||||||
|
|
||||||
console.log("Done!")
|
console.log("Done!")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user