Ultimamente volevo ascoltare qualche web-radio ma non mi andava giù di dover tenere per forza aperta una pagina web su virgin o capital,perciò mi sono scritto questo semplice script in python per ascoltare direttamente le mie web-radio preferite direttamente dal terminale sfruttando mplayer.
Per poter utilizzare il mio script dovete installare mplayer con il comando:
apt-get install mplayer
e poi basta che digitate nel terminale :
python radio.py
per far partire lo script e scegliere la radio
Eccovi lo script:
"""
* Copyright (C) 2009 Nunzio Alberto Favaro' <darsana85@libero.it>
*
* This script is a web-radio listener
*
* radio 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
* any later version.
*
* radio 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
import os
radio={"Radio_Giovane_Sicilia":"http://74.63.192.162:8020/","Virgin Live":"http://151.1.245.1/20","Virgin Rock Classic":"mms://151.1.245.1/24","Virgin Rock Extreme":"mms://151.1.245.1/25","Virgin Rock Alternative":"mms://151.1.245.1/36"}
a=[]
for name in enumerate(radio.keys()): # enumerate return tuple
print name[0],"-",name[1]
a.append(name[1])
try:
i=input("Scegli radio >>> ")
if (0 <= i < len(a)):
os.system("mplayer %s"% radio[a[i]])
else:
print "Wrong number!"
except:
print "ERROR restart script!"
Leggi il resto dell'articolo..Termini legati all'articolo: mplayer, python, radio, script, web, web-radio, webradio


