EvilZone
Programming and Scripting => Scripting Languages => Topic started by: 0poitr on April 02, 2013, 10:46:25 PM
-
This is bash script I wrote sometime back to listen internet radio.
Needs mplayer.
To change station while playing, just press enter. Sations are choosen by their serial number.
Add as many stations as you like in the array. You can also save the sound stream as mp3. Just press 'c' while playing. It'll be saved in pwd as <station_name><date>.mp3
#!/bin/bash
#black=`tput setaf 0`
#red=`tput setaf 1`
#green=`tput setaf 2`
#yellow=`tput setaf 3`
#blue=`tput setaf 4`
#magenta=`tput setaf 5`
cyan=`tput setaf 6`
white=`tput setaf 7`
norm=`tput sgr0`
bold=`tput bold`
#ulbegin=`tput smul`
#ulend=`tput rmul`
ser="$white"
name="$bold$cyan"
stations=(
Pvibe:ambient="http://67.212.233.124:8008"
Pvibe:house="http://67.212.233.124:8006"
Pvibe:dance="http://67.212.233.124:8000"
Pvibe:psycho="http://67.212.233.124:8010"
Pvibe:trance="http://67.212.233.124:8004"
Pvibe:breakbeat="http://67.212.233.124:8012"
Pvibe:dubstep="http://67.212.233.124:8014"
Pvibe:hardcore="http://67.212.233.124:8002"
Nirvana="http://91.121.72.50:9106"
Smooth="http://uk1.internet-radio.com:4086"
Zenradio="http://zenradio.fr:8800"
RadioParadise="http://stream-sd.radioparadise.com:9000/rp_128.mp3"
Groovsalad="http://mp1.somafm.com:8032"
Goa="http://sfstream1.somafm.com:8850"
MissionControl="http://sfstream1.somafm.com:2020"
)
#show_inf () {
#
# }
while(true); do
index=0
echo
for i in "${stations[@]}"; do
echo ${ser}$index.${norm} ${name}${i%%=*}${norm}
index=$[index+1]
done
echo
read -p "${cyan}Station:${norm} " sta
echo
capture="-capture -dumpfile ${stations[$sta]%%=*}_`date "+%T_%F"`.mp3"
#tfile=`mktemp`
mplayer -vc null -vo null -nolirc -msglevel all=4 ${capture} -msgcolor `echo ${stations[$sta]} | cut -d '=' -f2` 2>&1 | sed -n '/Name/,/Bitrate/ p'
echo -ne "${cyan}\nPress Entr to change station or, wait to exit${norm}"
read -t 5
[[ $? -gt 128 ]] && { echo && exit 0; }
#rm $tfile
unset -v index sta capture
done
exit 0
-
Very nice ,thanks for sharing :)
-
This is cool bro :D however in a graphical environment I prefer to use VLC :)
-
This is cool bro :D however in a graphical environment I prefer to use VLC :)
GUI's are overrated :)
-
I've always been a fanboy of the *nix shell. :D
-
I've always been a fanboy of the *nix shell. :D
Count me in :)
I fully understand what you are saying.