-
Modification to use an Orange Pi Zero
05/28/2017 at 19:21 • 0 commentsTo use the script on an orange pi zero, few modifications need to be made :
First use a different player : MPG123 is good
sudo apt-get install mpg123
in the script : use mpg123 instead of omxplayer :
#omxplayer $FILNAME mpg123 $FILNAME
As the player is compatible with alsa, add a line to set the volume in the 7-9_player.sh (anywhere before starting the player) :
amixer sset 'Lineout volume control' 65%
Without the extention board, the audio output is not filtered, a RC filter might be needed.
The wifi configuration has to be set manually :
sudo nano /etc/network/interfaces #---------------------------------- #COPY #---------------------------------- auto lo iface lo inet loopback auto eth0 allow-hotplug eth0 iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp #--------------------------------- #Ctrl + O #Enter #Ctrl + X sudo nano /etc/wpa_supplicant/wpa_supplicant.conf #---------------------------------- #COPY #---------------------------------- ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="WIFI_MaBox" psk="------------------" } #---------------------------------- #Change based on your WiFi Settings #Ctrl + O #Enter #Ctrl + X sudo reboot
-
Script explanation
04/07/2017 at 21:41 • 0 commentsPut 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