This commit is contained in:
Jeffrey Serio 2024-04-02 12:32:26 -05:00
parent 7901f31322
commit bdc8562d90
3 changed files with 27 additions and 23 deletions

View File

@ -1,11 +1,11 @@
#!/usr/bin/env nu #!/usr/bin/env nu
( (
transmission-remote -n 'transmission:transmission' -l | transmission-remote -n 'transmission:transmission' -l
from ssv | | from ssv
to html | | to html
str replace '<style>body { background-color:white;color:black; }</style>' '<head><title>Armbian torrent stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head>' | | str replace '<style>body { background-color:white;color:black; }</style>' '<head><title>Armbian torrent stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head>'
save -f -r /home/jas/staging/armbian-torrentstats.html | save -f -r /home/jas/staging/armbian-torrentstats.html
) )
scp /home/jas/staging/armbian-torrentstats.html jas@192.168.2.102:/home/jas/public/html/armbian-torrentstats.html scp /home/jas/staging/armbian-torrentstats.html jas@192.168.2.102:/home/jas/public/html/armbian-torrentstats.html

View File

@ -8,8 +8,8 @@ chmod 700 $temp_dir
# Download the torrents archive and save to temporary directory # Download the torrents archive and save to temporary directory
let torrent_zip = ($temp_dir | path join "armbian-torrents.zip") let torrent_zip = ($temp_dir | path join "armbian-torrents.zip")
( (
http get -r "https://dl.armbian.com/torrent/all-torrents.zip" | http get -r "https://dl.armbian.com/torrent/all-torrents.zip"
save -r $torrent_zip | save -r $torrent_zip
) )
# Test torrent_zip for corruption # Test torrent_zip for corruption
@ -23,12 +23,12 @@ unzip -o $torrent_zip -d ($temp_dir | path join "torrent-tmp") | ignore
# Create list of current active Armbian torrent ids # Create list of current active Armbian torrent ids
let armbian_torrent_ids = ( let armbian_torrent_ids = (
transmission-remote -n 'debian-transmission:debian-transmission' -l | transmission-remote -n 'debian-transmission:debian-transmission' -l
from ssv | | from ssv
drop nth 0 | | drop nth 0
drop | | drop
find "Armbian" | | find "Armbian"
get ID | get ID
) )
# Remove torrents from armbian_torrent_ids # Remove torrents from armbian_torrent_ids
@ -43,9 +43,9 @@ $armbian_torrent_ids | each {
# Add new/updated Armbian torrents # Add new/updated Armbian torrents
( (
ls ($temp_dir | path join "torrent-tmp") | ls ($temp_dir | path join "torrent-tmp")
get name | | get name
each { | each {
|torrent| |torrent|
transmission-remote -n 'debian-transmission:debian-transmission' -a $"($torrent)" transmission-remote -n 'debian-transmission:debian-transmission' -a $"($torrent)"
} | ignore } | ignore

View File

@ -1,11 +1,15 @@
#!/usr/bin/env nu #!/usr/bin/env nu
( let old_head = "<html><style>body { background-color:white;color:black; }</style><body>"
transmission-remote -l | let new_head = (
from ssv | ["<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>"]
to html | | str join ' '
str replace '<style>body { background-color:white;color:black; }</style>' '<head><title>Torrent stats</title><link type="text/css" rel="stylesheet" href="style2.css"/></head>' |
save -f -r /home/jas/public/html/torrentstats.html
) )
chown jas:jas /home/jas/public/html/torrentstats.html (
transmission-remote -l
| from ssv
| to html
| str replace ($old_head) ($new_head)
| save -f -r /home/jas/public/html/torrentstats.html
)