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
(
transmission-remote -n 'transmission:transmission' -l |
from ssv |
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>' |
save -f -r /home/jas/staging/armbian-torrentstats.html
transmission-remote -n 'transmission:transmission' -l
| from ssv
| 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>'
| 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

View File

@ -8,8 +8,8 @@ chmod 700 $temp_dir
# Download the torrents archive and save to temporary directory
let torrent_zip = ($temp_dir | path join "armbian-torrents.zip")
(
http get -r "https://dl.armbian.com/torrent/all-torrents.zip" |
save -r $torrent_zip
http get -r "https://dl.armbian.com/torrent/all-torrents.zip"
| save -r $torrent_zip
)
# 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
let armbian_torrent_ids = (
transmission-remote -n 'debian-transmission:debian-transmission' -l |
from ssv |
drop nth 0 |
drop |
find "Armbian" |
get ID
transmission-remote -n 'debian-transmission:debian-transmission' -l
| from ssv
| drop nth 0
| drop
| find "Armbian"
| get ID
)
# Remove torrents from armbian_torrent_ids
@ -43,9 +43,9 @@ $armbian_torrent_ids | each {
# Add new/updated Armbian torrents
(
ls ($temp_dir | path join "torrent-tmp") |
get name |
each {
ls ($temp_dir | path join "torrent-tmp")
| get name
| each {
|torrent|
transmission-remote -n 'debian-transmission:debian-transmission' -a $"($torrent)"
} | ignore

View File

@ -1,11 +1,15 @@
#!/usr/bin/env nu
(
transmission-remote -l |
from ssv |
to html |
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
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="style2.css"/></head><body><h4>Last updated:", (date now | format date "%F %T%:z"), "</h4>"]
| str join ' '
)
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
)