Put the current day, month, year in a string using the format dd.mm.yyyy
DATE=`date +%d.%m.%Y`
Select the script directory, the user must have the write permition so it won't crash when launched by CRON
cd /home/pi/Documents/
Remove the old rss file, you don't want to use outdated data
rm rss_10241.xml
Get the new rss file, it will be saved as rss_10241.xml in the active directory (that's why we need writing right)
The podcast file will have a new name everyday, this name will include the date.
wget http://radiofrance-podcast.net/podcast09/rss_10241.xml
Create a pattern to find the podcast in the rss file, note that alnum is used because those numbers can't be deducted from the date (they appear to be random but increasing)
FILENAME_PATTERN="10241-"$DATE"-ITEMA_[[:alnum:]]*-[[:alnum:]]*.mp3"
Create a pattern to find the complete address of the pod cast
PATTERN="http://media.radiofrance-podcast.net/podcast09/10241-"$DATE"-ITEMA_$
Find the adress in the rss file using the pattern
MP3_ADDRESS=`grep $PATTERN rss_10241.xml -o`
Find the exact filename using the second pattern
FILNAME=`grep $FILENAME_PATTERN rss_10241.xml -o`
Get the file ! this can take a while depending of your internet speed
wget $MP3_ADDRESS
Wait until it's wake up time (badly made...)
heure=`date +%H`
while [ $heure -lt 9 ]
do
#echo "waiting hour"
heure=`date +%H`
done
minute=`date +%M`
while [ $minute -lt 30 ]
do
#echo "waiting minute"
heure=`date +%M`
done
echo "running"
Play the file, wake up, have breakfast,...
omxplayer $FILNAME
Clean before leaving, it's common courtesy
rm rss_10241.xml
rm $FILNAME
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.