More configuration

This commit is contained in:
Martin Brodbeck 2013-09-13 21:55:38 +02:00
parent 8e47e88dc8
commit 74f1f787f8
2 changed files with 8 additions and 4 deletions

View file

@ -46,8 +46,8 @@ def read_settings():
config.read(settings_base_dir + 'settings.ini')
return dict(config.items())
def record(stoprec, streamurl):
target = open('./test.mp3', "wb")
def record(stoprec, streamurl, target_dir):
target = open(target_dir + '/test.mp3', "wb")
conn = urllib.request.urlopen(streamurl)
#print(conn.getheader('Content-Type'))
while(not stoprec.is_set() and not conn.closed):
@ -58,14 +58,15 @@ def main():
settings = read_settings()
streamurl = ''
try:
settings['STATIONS'][args.station]
streamurl = settings['STATIONS'][args.station]
except KeyError:
print('Unkown station name: ' + args.station)
return
target_dir = os.path.expandvars(settings['GLOBAL']['target_dir'])
stoprec = threading.Event()
recthread = threading.Thread(target = record,
args = (stoprec, streamurl), daemon = True)
args = (stoprec, streamurl, target_dir), daemon = True)
recthread.start()
recthread.join(args.duration * 60)

View file

@ -1,2 +1,5 @@
[GLOBAL]
target_dir = $HOME/Arbeitsfläche
[STATIONS]
dlf = http://dradio_mp3_dlf_m.akacast.akamaistream.net/7/249/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dlf_m