Sunday, May 6, 2012

Playing Radio Stream with Bash Script

Small bash script I wrote to play radio streams trough mplayer. It shows a simple radio list where one can choose the radio stream to be played.
I wrote this a long time ago and it has still some thing written in spanish but it is cery simple and you will find it pretty straight forward.


radio.sh
#!/bin/bash

#Emisoras

SER="http://194.169.201.177:8085/liveser.mp3"
AWESOME80="http://uplink.duplexfx.com:8000"
LITE80="http://uplink.duplexfx.com:8040"
HAIRBAND="http://uplink.duplexfx.com:8014"
THEHEART="http://uplink.duplexfx.com:8006"
BEATLES="http://uplink.duplexfx.com:8062"
GOODTIMEOLDIES="http://uplink.duplexfx.com:8046"
CLASSICALGUITAR="http://uplink.duplexfx.com:8020"

#Comprobar mplayer instalado
PLAYER=$(which mplayer 2> /dev/null)
if [ -z "$PLAYER" ]; then
    printf "Instala mplayer!\n"
    exit 1
fi

DIALOG=$(which dialog 2> /dev/null)
if [ -z "$DIALOG" ]; then
    printf "Instala dialog!\n"
    exit 1
fi

#Terminar con mplayer
killall 2> /dev/null "$PLAYER"

#Seleccionar emisora
EMISORA=$($DIALOG --stdout --title "Radio" --radiolist "Emisoras" 0 0 0 "Cadena SER" "" ON "Awesome 
80's" "" OFF "Lite 80's" "" OFF "80's Hairband" "" OFF "The Heart" "" OFF "Beatles" "" OFF "Good 
Time Oldies" "" OFF "Classical Guitar" "" OFF)

clear

case $EMISORA in
    "Cadena SER")
        printf "Playing Cadena SER\n"
        "$PLAYER" 2>/dev/null "$SER" ;;
    "Awesome 80's")
        printf "Playing Awesone 80's\n"
        "$PLAYER" 2>/dev/null "$AWESOME80" ;;
    "Lite 80's")
        printf "Playing Lite 80's\n"
        "$PLAYER" 2>/dev/null "$LITE80" ;;
    "80's Hairband")
        printf "Playing 80's Hairband\n"
        "$PLAYER" 2>/dev/null "$HAIRBAND" ;;
    "The Heart")
        printf "Playing The Heart\n"
        "$PLAYER" 2>/dev/null "$THEHEART" ;;
    "Beatles")
        printf "Playing Beatles\n"
        "$PLAYER" 2>/dev/null "$BEATLES" ;;
    "Good Time Oldies")
        printf "Playing Good Time Oldies\n"
        "$PLAYER" 2>/dev/null "$GOODTIMEOLDIES" ;;
    "Classical Guitar")
        printf "Playing Classical Guitar\n"
        "$PLAYER" 2>/dev/null "$CLASSICALGUITAR" ;;
    *)
        printf "No se ha encontrado la emisora.\n" ;;
esac

exit 0
Running the script:

5 comments:

  1. A point, no I dont find it easy to understand or read, these are all binary digits and I am no computer geek to be able to understand all of this without help.

    ReplyDelete
  2. I read this article. I think You put a lot of effort to create this article. I appreciate your work. download instagram stories

    ReplyDelete
  3. This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post.
    picta

    ReplyDelete
  4. Your article is such an informative article. It is glad to read such those articles. Thanks for sharing.

    ReplyDelete
  5. What a good and informative post here. I read this article three time and ever time i get very good stuff here. Thanks for it. 192.168.l.254 -It’s used to enter in web-interface which also known as admin panel

    ReplyDelete