#!/usr/bin/python

"""
radio.py 0.1

A script that makes it easy to listen to online radio via mplayer

"""


###########################################################################
 #   Copyright (C) 2007 by Guy Rutenberg                                   #
 #   guyrutenberg@gmail.com                                                #
 #                                                                         #
 #   This program is free software; you can redistribute it and/or modify  #
 #   it under the terms of the GNU General Public License as published by  #
 #   the Free Software Foundation; either version 2 of the License, or     #
 #   (at your option) any later version.                                   #
 #                                                                         #
 #   This program is distributed in the hope that it will be useful,       #
 #   but WITHOUT ANY WARRANTY; without even the implied warranty of        #
 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
 #   GNU General Public License for more details.                          #
 #                                                                         #
 #   You should have received a copy of the GNU General Public License     #
 #   along with this program; if not, write to the                         #
 #   Free Software Foundation, Inc.,                                       #
 #   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################

import sys,os

radiostations = {#name:(address,description),
        'Galgalatz':('http://gifs.msn.co.il/media/gglz.asx',''),
        'Radio Tel Aviv':('http://switch3.castup.net/cunet/gm.asp?clipmediaid=30795',''),
        'Galatz':('http://gifs.msn.co.il/media/glz.asx',''),
	'RB':('http://switch3.castup.net/cunet/gm.asp?ai=31&ar=Reshet%5FBet',''),
        'Reshet Bet':('http://switch3.castup.net/cunet/gm.asp?ai=31&ar=Reshet%5FBet',''),
        'Reshet Gimel':('http://switch3.castup.net/cunet/gm.asp?ai=31&ar=Gimel',''),
	'Seattle':('http://spraydio.se/player/asx.jsp?room=seattle&amp;spot=false',''),
	'99ESC':('http://s18wm.castup.net/991791101-52.wmv',''),
        '103FM':('http://live.103.fm/103fm-low/',''),
        '100FM':('http://213.8.143.164/audiomedia',''),
        'Haifa':('mms://192.117.122.35/radio','')
        }

if len(sys.argv)<1:
        print "you need to supply a station name"
        sys.exit(1)

try:
        radiostations[sys.argv[1]]
except KeyError:
        print "Didn't recognized this station name:",sys.argv[1]
        sys.exit(1)

args=['mplayer', '-softvol', '-playlist', radiostations[sys.argv[1]][0] ]
os.execvp(args[0],args)
