Browse Source

Factor out common function for streaming songs. Simplify process killing.

master
Dan Helfman 3 months ago
parent
commit
ba42971bef
  1. 29
      play-by-number

29
play-by-number

@ -2,27 +2,26 @@
set -e
stream_song () {
subsonic-cli -c subsonic-cli.cfg stream -p id $1 | mpv --no-video -
}
while [ true ] ; do
read -s -n 1 key
read -s -n 1 song_number
if [[ ! -z "$last_command" ]]; then
kill -9 "$last_command" || true
fi
killall -9 mpv || true
case $key in
case $song_number in
1) mpv --no-video https://somafm.com/poptron.pls & ;;
2) subsonic-cli -c subsonic-cli.cfg stream -p id 05211b7eb16eca0729307459ad31056a | mpv --no-video - & ;; # What does the fox say
3) subsonic-cli -c subsonic-cli.cfg stream -p id 2d526af565131fceaab63bf970df49ea | mpv --no-video - & ;; # Bananaphone
4) subsonic-cli -c subsonic-cli.cfg stream -p id 6b35d311b9bba0d6f6de654a02963849 | mpv --no-video - & ;; # The Duck Song
5) subsonic-cli -c subsonic-cli.cfg stream -p id 20ab5ea1d53aead4ad99bd7c50b2040b | mpv --no-video - & ;; # The Duck Song 2
6) subsonic-cli -c subsonic-cli.cfg stream -p id ef44e283de5509b11e4422c441da2951 | mpv --no-video - & ;; # The Duck Song 3
7) subsonic-cli -c subsonic-cli.cfg stream -p id 3a26a5950b11886cd50d2f05d9c244f3 | mpv --no-video - & ;; # Fire Truck
8) subsonic-cli -c subsonic-cli.cfg stream -p id c6c5040d29c9eaaaf11f30f5415eab5b | mpv --no-video - & ;; # Raining Tacos
*) last_command=; continue
2) stream_song 05211b7eb16eca0729307459ad31056a & ;; # What does the fox say
3) stream_song 2d526af565131fceaab63bf970df49ea & ;; # Bananaphone
4) stream_song 6b35d311b9bba0d6f6de654a02963849 & ;; # The Duck Song
5) stream_song 20ab5ea1d53aead4ad99bd7c50b2040b & ;; # The Duck Song 2
6) stream_song ef44e283de5509b11e4422c441da2951 & ;; # The Duck Song 3
7) stream_song 3a26a5950b11886cd50d2f05d9c244f3 & ;; # Fire Truck
8) stream_song c6c5040d29c9eaaaf11f30f5415eab5b & ;; # Raining Tacos
esac
# TODO: Gummy Bear song
# TODO: Enter after typing numbers? To allow more songs.
last_command=$!
done

Loading…
Cancel
Save