I just did a rough test with squeezelite log level setting set to
"stream=info", then running the below script and cycling through some
local tracks and internet streams. The script just copies the log file
and then compares the log to the copy every .3 seconds and if they are
different gets the new track info and writes the title to stdout. Brute
force yes but it was really responsive to changes, virtually no lag in
detecting the change and writing out the track title. You can see that
some titles are repeated though, which is I'm sure to do with timing of
the log writing and comparing, so on some loops the log content has
changed even though the track hasn't. I'll just have to do a few more
checks to minimize false positives. The output below is local tracks
and the beginning and then internet streams at the end. The internet
streams produced more repeats. I think there is more delay to log
writes which triggers more false positives.
Anyway, I'm sort of liking it!
Code:
--------------------
root@pi3-LMS:/home/tc/sod-npd# cat script.sh
#!/bin/sh
post=$(cat <<'END_HEREDOC'
POST /jsonrpc.js HTTP/1.1
HOST: 192.168.1.201:9000
Content-Type: application/json; charset=utf-8
Content-Length: 97
{"id":1,"method":"slim.request","params":["b8:27:eb:94:ae:63",["status","-","1","tags:acgltys"]]}
END_HEREDOC
)
cp /var/log/pcp_squeezelite.log last.log
while :
do
if `cmp -s /var/log/pcp_squeezelite.log last.log`
then
sleep .3
else
cp /var/log/pcp_squeezelite.log last.log
(echo -e "$post"; sleep .1) | nc 192.168.1.201 9000 | tail --line=+7 | awk -f
/usr/local/bin/JSON.awk - | grep -m 1 '0,"title"' | cut -f2 | cut -d '"' -f2
fi
done
--------------------
Code:
--------------------
root@pi3-LMS:/home/tc/sod-npd# ./script.sh
Dont Go Like That, No
Every Gauge Is On Empty
Mathematicians
Sweaters
I Just Wanna Go Home
Green With Envy
Makin Faces Like (You Ate A Lemon)
Outside, Lookin In
Neon Signs
Dreaming The Day Away
Dont Go Like That, No
Dont Go Like That, No
Every Gauge Is On Empty
Sweaters
Sweaters
Sweaters
Frontier Ruckus - 27 Dollars
Frontier Ruckus - 27 Dollars
Frontier Ruckus - 27 Dollars
Dead Horses - Red Pony
Red Pony
Saban Saulic - Nismo vise tako mladi
Saban Saulic - Nismo vise tako mladi
Saban Saulic - Nismo vise tako mladi
Nihad Alibegovic - Sta Ucini Od Mog Zivota
Nihad Alibegovic - Sta Ucini Od Mog Zivota
Nihad Alibegovic - Sta Ucini Od Mog Zivota
Sta Ucini Od Mog Zivota
--------------------
------------------------------------------------------------------------
sodface's Profile: http://forums.slimdevices.com/member.php?userid=19057
View this thread: http://forums.slimdevices.com/showthread.php?t=109694
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix