Author Topic: [bash] Script to listen internet radio  (Read 2250 times)

0 Members and 2 Guests are viewing this topic.

Offline 0poitr

  • Peasant
  • *
  • Posts: 149
  • Cookies: 64
    • View Profile
[bash] Script to listen internet radio
« 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

Code: (bash) [Select]
#!/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
« Last Edit: April 03, 2013, 12:11:01 am by 0poitr »
Imagination is the first step towards Creation.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Script to listen internet radio
« Reply #1 on: April 03, 2013, 12:11:00 am »
Very nice ,thanks for sharing :)
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [bash] Script to listen internet radio
« Reply #2 on: April 03, 2013, 08:48:04 am »
This is cool bro :D however in a graphical environment I prefer to use VLC :)

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: [bash] Script to listen internet radio
« Reply #3 on: April 03, 2013, 08:54:05 am »
This is cool bro :D however in a graphical environment I prefer to use VLC :)

GUI's are overrated :)
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline 0poitr

  • Peasant
  • *
  • Posts: 149
  • Cookies: 64
    • View Profile
Re: [bash] Script to listen internet radio
« Reply #4 on: April 03, 2013, 09:42:58 am »
I've always been a fanboy of the *nix shell. :D
« Last Edit: April 03, 2013, 09:47:54 am by 0poitr »
Imagination is the first step towards Creation.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: [bash] Script to listen internet radio
« Reply #5 on: April 03, 2013, 04:53:12 pm »
I've always been a fanboy of the *nix shell. :D

Count me in :)
I fully understand what you are saying.
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage