mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-01 08:03:05 +01:00
Compare commits
6 Commits
e8428f1236
...
6efeee8ca9
Author | SHA1 | Date | |
---|---|---|---|
6efeee8ca9 | |||
da006b5919 | |||
11c3fda10f | |||
cc1a11c936 | |||
6efc4c19ae | |||
912edc2500 |
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
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="style2.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 ' '
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
transmission-remote -l
|
/home/jas/admin-scripts/list_torrents.py
|
||||||
| from ssv
|
| from ssv
|
||||||
| to html
|
| to html
|
||||||
| str replace ($old_head) ($new_head)
|
| str replace ($old_head) ($new_head)
|
||||||
| save -f -r /home/jas/public/html/torrentstats.html
|
| save -f -r /home/jas/public/html/torrents.html
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ def print_table():
|
|||||||
qb.login()
|
qb.login()
|
||||||
table = []
|
table = []
|
||||||
headers = ["Name", "Total Size", "Trackers Count", "Ratio", "Uploaded"]
|
headers = ["Name", "Total Size", "Trackers Count", "Ratio", "Uploaded"]
|
||||||
sorted_torrents = sorted(qb.torrents(), key=lambda d: d["name"]) # type: ignore
|
sorted_torrents = sorted(qb.torrents(), key=lambda d: d["ratio"], reverse=True) # type: ignore
|
||||||
for torrent in sorted_torrents:
|
for torrent in sorted_torrents:
|
||||||
row = []
|
row = []
|
||||||
row.append(torrent["name"]) # type: ignore
|
row.append(torrent["name"]) # type: ignore
|
||||||
@ -61,6 +61,20 @@ def print_table():
|
|||||||
print(tabulate(table, headers, tablefmt="grid"))
|
print(tabulate(table, headers, tablefmt="grid"))
|
||||||
|
|
||||||
|
|
||||||
|
def print_ssv():
|
||||||
|
qb = Client("http://localhost:8080/")
|
||||||
|
qb.login()
|
||||||
|
sorted_torrents = sorted(qb.torrents(), key=lambda d: d["ratio"], reverse=True) # type: ignore
|
||||||
|
print("Name Size Trackers Ratio Uploaded")
|
||||||
|
for torrent in sorted_torrents:
|
||||||
|
name = torrent["name"] # type: ignore
|
||||||
|
size = human_bytes(int(torrent["total_size"])) # type: ignore
|
||||||
|
trackers = torrent["trackers_count"] # type: ignore
|
||||||
|
ratio = torrent["ratio"] # type: ignore
|
||||||
|
uploaded = human_bytes(int(torrent["uploaded"])) # type: ignore
|
||||||
|
print(f"{name} {size} {trackers} {ratio} {uploaded}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
args = docopt(__doc__) # type: ignore
|
args = docopt(__doc__) # type: ignore
|
||||||
print_table()
|
print_ssv()
|
||||||
|
15
qbt_stats_html.nu
Executable file
15
qbt_stats_html.nu
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
|
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/main-style.css"/></head><body><h4>Last updated:", (date now | format date "%F %T%:z"), "</h4>"]
|
||||||
|
| str join ' '
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
/home/jas/admin-scripts/list_torrents.py
|
||||||
|
| from ssv -m 2
|
||||||
|
| to html
|
||||||
|
| str replace ($old_head) ($new_head)
|
||||||
|
| save -f -r /home/jas/public/html/torrents.html
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user