From 74f1f787f83ee086f8c2a3a4af5f9a50a3be68d7 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Fri, 13 Sep 2013 21:55:38 +0200 Subject: [PATCH] More configuration --- radiorec.py | 9 +++++---- settings.ini | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/radiorec.py b/radiorec.py index 2df79ae..e7a5b80 100755 --- a/radiorec.py +++ b/radiorec.py @@ -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) diff --git a/settings.ini b/settings.ini index 47962e8..20ff6ec 100644 --- a/settings.ini +++ b/settings.ini @@ -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