TV Rotations for Broadcast [#!Script]

I wrote this script originally for an FM station I run for the residents in my building. It will shuffle at each end of a self generated playlist; provides option to add a video/audio file every X number of videos/audios after being shuffled in a playlist.

The user can add more for rotations of content that is repeated within the shuffle self-generated playlist. Removing or adding the “–no-video” switch to the mpv command at end of script determines audio vs video programming for the overall use of this script.

The script may also be adapted for headless operation from a thumb driving containing the modifiable script and the video files for the programming on a Raspberry Pi 3/4.

# unmute for automount of USB thumb drive operation with toggling the pound '#' symbol for mute/unmute.

# sudo mount /dev/sda1 ~/m     

# create a file based on a text file that is text to speech read and saved as a wave

espeak -f radio.txt -q -a 100 -s 100 -w radio.wav  

# test out the created wave file that can be used later and added to rotations after the shuffle.

mpv radio.wav 
while :

# put in a loop creation of list of all material, video and audio to be 
shuffled later in the playlist.

 find "$PWD" | grep .mp3 > play.pls
 find "$PWD" | grep .mp4 >> play.pls
 find "$PWD" | grep .mkv >> play.pls
 find "$PWD" | grep .webm >> play.pls
 find "$PWD" | grep .m4a >> play.pls
 find "$PWD" | grep .3gp >> play.pls

# shuffle the playlist contents

 shuf play.pls > ./p.pls

# change radio.wav to any other file that you want in rotations outside of the shuffle. Also you can change %6 to another number for how many video passes before running the file (audio/video)

awk '{print}; NR%6==0 {print "radio.wav"}' p.pls > ply.pls 

# play the files from the shuffled generated playlist file. Add --no-video flag before --playlist to suppress video output and pass only audio.

mpv --playlist=ply.pls