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 filesmpc ls - list all music files in music directorympc clear - clear the playlistmpc ls | grep -v "^Speech" | sort --random-sort | tail -1 | mpc add - add one random song to playlistmpc ls | grep "^Speech" | sort --random-sort | tail -1 | mpc add - add one random speach to playlistmpc play - start playing playlistmpc playlist - show the playlistOK. 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:
Post a Comment