A screenless music player for kids. Play particular songs or internet radio stations by typing numbers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.5 KiB

#!/bin/bash
set -e
function kill_music_processes() {
killall -9 mpv || true
}
apply_quiet_hours () {
hour=$(TZ="America/Los_Angeles" date +"%H")
if [ $hour -ge 21 ] || [ $hour -le 7 ] ; then
kill_music_processes
fi
if [ $hour -ge 20 ] || [ $hour -le 8 ] ; then
amixer sset 'Master' 50%
else
amixer sset 'Master' 85%
fi
sleep 1m
}
stream_song () {
subsonic-cli -c subsonic-cli.cfg stream -p id "$1" | mpv --no-video --no-input-terminal - &
}
stream_radio() {
mpv --no-video --no-input-terminal "$1" &
}
stream_christmas_radio() {
month=$(TZ="America/Los_Angeles" date +"%m")
if [ $month -ge 12 ] ; then
mpv --no-video --no-input-terminal "$1" &
else
play_local media/shush.mp3
fi
}
play_local() {
mpv --no-video --no-input-terminal "$1" &
}
trap kill_music_processes EXIT
apply_quiet_hours &
while [ true ] ; do
read -s song_number
hour=$(TZ="America/Los_Angeles" date +"%H")
if [ $hour -ge 21 ] || [ $hour -le 7 ] ; then
play_local media/shush.mp3
continue
fi
kill_music_processes
case $song_number in
0) stream_radio https://somafm.com/dronezone256.pls ;; # Drone Zone
1) stream_radio https://somafm.com/poptron.pls ;; # Poptron
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
9) stream_song a0e145806d461cf7bc98a668a40db5b8 ;; # I Am a Gummy Bear
10) stream_song 01572074cfede785f65cbe98b16d9bc8 ;; # Let it Go (Frozen)
11) stream_song f023f03291c2494918ce819d847611cc ;; # I Like Vegetables
12) stream_song f96caa83bad419d2e29b7f30538bfc95 ;; # Pinkalicious theme song
13) stream_radio https://somafm.com/groovesalad256.pls ;; # Groove Salad
90) stream_christmas_radio https://somafm.com/christmas256.pls ;; # Christmas Lounge
91) stream_christmas_radio https://somafm.com/xmasrocks.pls ;; # Christmas Rocks!
92) stream_christmas_radio https://somafm.com/jollysoul.pls ;; # Jolly Ol' Soul
*) play_local media/error_beep.mp3 ;;
esac
done