Intelligent radio with Raspberry Pi

I am still using my home radio to play some positive and inspiring music.

Later i have need to create some intelligent background in radio for example:
I want to inject some random speech between every two songs.
Another rule i want is that one song can be played only once a day. Same rule for Speeches.

I ended up to controlling this with simple mp3 file names for example:
Every file name which starts with "Speech" is not a song but a speech.
Every file name which not starts with "Speech" is a song.
So it is two separated lists in memory which i work with.

To implement this application i use following commands:
mpc update - reread the directory of music files

mpc ls - list all music files in music directory

mpc clear - clear the playlist

mpc ls | grep -v "^Speech" | sort --random-sort | tail -1 | mpc add - add one random song to playlist

mpc ls | grep "^Speech" | sort --random-sort | tail -1 | mpc add - add one random speach to playlist

mpc play - start playing playlist

mpc playlist - show the playlist

OK. I am not proud of this code but at least it get the job done.
I am very proud for commenting code as much as possible :)
Project on github:
https://github.com/catonrug/radio-intelekts/blob/master/intelekts.sh

No comments: