#! /usr/bin/python

# Module importieren
import os
import sys
import curses

#Lautstaerke setzen
volume = 32 
os.system('amixer set Master ' + str(volume))
# Curses Modus starten
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
# Standardsender OE1
os.system ('mplayer -really-quiet -ao alsa ./ansagen/oe1.mp3 < /dev/null > /dev/null &')
os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 mms://apasf.apa.at/oe1_live_worldwide < /dev/null > /dev/null &')
# Texthilfe
pad = curses.newpad(30,10)
pad.addstr(1,1,'1 OE1')
pad.refresh(1,1,1,1,30,7)

while True:
	c = stdscr.getch()
# lauter	
	if c == curses.KEY_RIGHT:
	    if volume < 64:
			volume = volume + 4
			os.system ('mplayer -really-quiet -ao alsa ./ansagen/lauter.mp3 < /dev/null > /dev/null &')
			os.system('amixer set Master ' + str(volume))			
# leister			
	if c == curses.KEY_DOWN:
	    if volume > 0:		
			volume = volume - 4
			os.system ('mplayer -really-quiet -ao alsa ./ansagen/leiser.mp3 < /dev/null > /dev/null &')
			os.system('amixer set Master ' + str(volume))
# Sender je nach gedrueckter Taste abspielen			
	elif c == ord('1'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/oe1.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 mms://apasf.apa.at/oe1_live_worldwide < /dev/null > /dev/null &')
	elif c == ord('2'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_wien.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 mms://apasf.apa.at/radio_wien_worldwide < /dev/null > /dev/null &')
	elif c == ord('y') or c == ord('Y'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/dlf.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.dradio.de/streaming/dlf.m3u < /dev/null > /dev/null &')
	elif c == ord('x') or c == ord('X'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/dw.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 http://c13010-ls.i.core.cdn.streamfarm.net/dwworldlive-live/13010dwrde64.mp3 < /dev/null > /dev/null &')
	elif c == ord('c') or c == ord('C'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/hr1.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://metafiles.gl-systemhaus.de/hr/hr1_2.m3u < /dev/null > /dev/null &')
	elif c == ord('v') or c == ord('V'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/hr2.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://metafiles.gl-systemhaus.de/hr/hr2_2.m3u < /dev/null > /dev/null &')
	elif c == ord('b') or c == ord('B'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/hr3.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u < /dev/null > /dev/null &')
	elif c == ord('n')  or c == ord('N'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/hr4.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://metafiles.gl-systemhaus.de/hr/hr4_2.m3u < /dev/null > /dev/null &')
	elif c == ord('m') or c == ord('M'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/hr_info.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://metafiles.gl-systemhaus.de/hr/hrinfo_2.m3u < /dev/null > /dev/null &')
	elif c == ord(','):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/ndr1_niedersachsen.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 http://ndr.ic.llnwd.net/stream/ndr_ndr1niedersachsen_hi_mp3 < /dev/null > /dev/null &')
	elif c == ord('.'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/mdr_sachsen.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://avw.mdr.de/livestreams/mdr1_radio_sachsen_live_128.m3u < /dev/null > /dev/null &')
	elif c == ord('-'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/mdr_classic.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://avw.mdr.de/livestreams/mdr_figaro_classic_128.m3u < /dev/null > /dev/null &')
	elif c == ord('h') or c == ord('H'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/mdr_info.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://avw.mdr.de/livestreams/mdr_info_live_128.m3u < /dev/null > /dev/null &')
	elif c == ord('j') or c == ord('J'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/rbb_info.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 mms://stream2.rbb-online.de/wmtencoder/inforadio-live.wma < /dev/null > /dev/null &')
	elif c == ord('k') or c == ord('K'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/rbb_kultur.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 mms://stream2.rbb-online.de/wmtencoder/kulturradio-live.wma < /dev/null > /dev/null &')
	elif c == ord('l') or c == ord('L'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/rbb_radio1.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 mms://stream2.rbb-online.de/wmtencoder/radioeins-live.wma < /dev/null > /dev/null &')
	elif c == ord('+'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/ndr1_welle_nord.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 http://ndr.ic.llnwd.net/stream/ndr_ndr1wellenord_hi_mp3 < /dev/null > /dev/null &')
	elif c == ord('#'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/wdr2.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.wdr.de/wdrlive/media/wdr2.m3u < /dev/null > /dev/null &')
	elif c == ord('q') or c == ord('Q'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_news.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/worldservice/meta/tx/nb/live/ennws.ram < /dev/null > /dev/null &')
	elif c == ord('w') or c == ord('W'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_uk.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/worldservice/meta/tx/nb/live/eneuk.ram < /dev/null > /dev/null &')
	elif c == ord('e') or c == ord('E'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_radio1.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/radio/listen/live/r1.ram < /dev/null > /dev/null &')
	elif c == ord('r') or c == ord('R'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_radio2.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/radio/listen/live/r2.ram < /dev/null > /dev/null &')
	elif c == ord('t') or c == ord('T'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_radio4.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/radio/listen/live/r4.ram < /dev/null > /dev/null &')
	elif c == ord('z') or c == ord('Z'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_radio5.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/radio/listen/live/r5l.ram < /dev/null > /dev/null &')
	elif c == ord('u') or c == ord('U'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bbc_radio3.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://www.bbc.co.uk/radio/listen/live/r3.ram < /dev/null > /dev/null &')
	elif c == ord('a') or c == ord('A'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bayern1.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://streams.br-online.de:80/bayern1_2.m3u < /dev/null > /dev/null &')
	elif c == ord('s') or c == ord('S'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bayern2.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://streams.br-online.de/bayern2_2.m3u < /dev/null > /dev/null &')
	elif c == ord('d') or c == ord('D'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bayern3.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://streams.br-online.de/bayern3_2.m3u < /dev/null > /dev/null &')
	elif c == ord('f') or c == ord('F'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bayern4.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://streams.br-online.de/bayern4klassik_2.m3u < /dev/null > /dev/null &')
	elif c == ord('g') or c == ord('G'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/bayern5.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -really-quiet -nolirc -ao alsa -cache 128 -playlist http://streams.br-online.de/b5aktuell_2.m3u < /dev/null > /dev/null &')
	elif c == ord('3'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/oe3.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://gcssrv.pkf.speednet.at/WSX/oe3_live &')
	elif c == ord('4'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/fm4.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://apasf.apa.at/fm4_live_worldwide &')
	elif c == ord('5'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_salzburg.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://streaming.conova.com/ORF_Salzburg_live &')
	elif c == ord('6'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/dw.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 http://c13010-ls.i.core.cdn.streamfarm.net/dwworldlive-live/13010dwrde64.mp3 &')
	elif c == ord('7'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_burgenland.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://apasf.apa.at/radio_bgl_worldwide &')
	elif c == ord('8'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_steiermark.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://apasf.apa.at/radio_stmk_worldwide &')
	elif c == ord('9'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_kaernten.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://gcssrv.pkf.speednet.at/WSX/oe2ktn &')
	elif c == ord('0'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_noe.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://radio-noe.streaming.kabsi.at/radio_noe &')
	elif c == ord('i') or c == ord('I'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_ooe.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://212.33.55.236/radioooe &')
	elif c == ord('o') or c == ord('O'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_tirol.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://apasf.apa.at/radio_tirol_worldwide &')
	elif c == ord('p') or c == ord('P'):
		os.system('killall mplayer')
		os.system ('mplayer -really-quiet -ao alsa ./ansagen/radio_vorarlberg.mp3 < /dev/null > /dev/null &')
		os.system('mplayer -nolirc -really-quiet -ao alsa -cache 128 mms://apasf.apa.at/radio_vbg_worldwide &')	
# Wartungsmodus mit PAGE DOWN (d.h. Programm sauber beenden)		
	elif c == curses.KEY_NPAGE:
		os.system('killall mplayer')
		break
# Curses Modus sauber beenden		
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
