-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnowplaying
26 lines (17 loc) · 913 Bytes
/
nowplaying
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
while pgrep vlc > /dev/null
do
sleep 1
curl -s -u :play http://127.0.0.1:8080/requests/status.xml -o /tmp/status.xml
length=$(xmllint --xpath '//length/text()' /tmp/status.xml)
elapsed_time=$(xmllint --xpath '//time/text()' /tmp/status.xml)
time_left=$(echo "$length-$elapsed_time" | bc)
xmllint --xpath '//information/category[@name="meta"]/info[@name="filename"]/text()' /tmp/status.xml > /tmp/nowplaying
echo -n "+" >> /tmp/nowplaying
printf '%dm:%ds' $(($elapsed_time%3600/60)) $(($elapsed_time%60)) >> /tmp/nowplaying
echo -n " -" >> /tmp/nowplaying
printf '%dm:%ds' $(($time_left%3600/60)) $(($time_left%60)) >> /tmp/nowplaying
sed -e "s/'/\'/g" -e 's/&/\&/g' -e 's/.mp3//gI' -e 's/.m4a//gI' -e 's/.mp4//gI' -e 's/.wav//gI' -e 's/.aac//gI' -e 's/.adts//gI' -e 's/.webm//gI' /tmp/nowplaying > /tmp/nowplaying2
done
rm /tmp/nowplaying
rm /tmp/nowplaying2