Compare commits

..

6 Commits

Author SHA1 Message Date
6efeee8ca9 Sort by descending seed ratio 2024-10-25 13:06:01 -05:00
da006b5919 Fix spaces 2024-10-25 12:57:34 -05:00
11c3fda10f Add minimum spaces = 1 2024-10-25 12:52:30 -05:00
cc1a11c936 Add qbt_torrent_stats_html.nu 2024-10-25 12:46:55 -05:00
6efc4c19ae Fix print_ssv() 2024-10-25 12:39:36 -05:00
912edc2500 Add ssv support 2024-10-25 11:56:21 -05:00
3 changed files with 34 additions and 5 deletions

View File

@ -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
) )

View File

@ -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
View 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
)