More configuration
This commit is contained in:
parent
8e47e88dc8
commit
74f1f787f8
2 changed files with 8 additions and 4 deletions
|
@ -46,8 +46,8 @@ def read_settings():
|
||||||
config.read(settings_base_dir + 'settings.ini')
|
config.read(settings_base_dir + 'settings.ini')
|
||||||
return dict(config.items())
|
return dict(config.items())
|
||||||
|
|
||||||
def record(stoprec, streamurl):
|
def record(stoprec, streamurl, target_dir):
|
||||||
target = open('./test.mp3', "wb")
|
target = open(target_dir + '/test.mp3', "wb")
|
||||||
conn = urllib.request.urlopen(streamurl)
|
conn = urllib.request.urlopen(streamurl)
|
||||||
#print(conn.getheader('Content-Type'))
|
#print(conn.getheader('Content-Type'))
|
||||||
while(not stoprec.is_set() and not conn.closed):
|
while(not stoprec.is_set() and not conn.closed):
|
||||||
|
@ -58,14 +58,15 @@ def main():
|
||||||
settings = read_settings()
|
settings = read_settings()
|
||||||
streamurl = ''
|
streamurl = ''
|
||||||
try:
|
try:
|
||||||
settings['STATIONS'][args.station]
|
streamurl = settings['STATIONS'][args.station]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print('Unkown station name: ' + args.station)
|
print('Unkown station name: ' + args.station)
|
||||||
return
|
return
|
||||||
|
target_dir = os.path.expandvars(settings['GLOBAL']['target_dir'])
|
||||||
stoprec = threading.Event()
|
stoprec = threading.Event()
|
||||||
|
|
||||||
recthread = threading.Thread(target = record,
|
recthread = threading.Thread(target = record,
|
||||||
args = (stoprec, streamurl), daemon = True)
|
args = (stoprec, streamurl, target_dir), daemon = True)
|
||||||
recthread.start()
|
recthread.start()
|
||||||
recthread.join(args.duration * 60)
|
recthread.join(args.duration * 60)
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
|
[GLOBAL]
|
||||||
|
target_dir = $HOME/Arbeitsfläche
|
||||||
|
|
||||||
[STATIONS]
|
[STATIONS]
|
||||||
dlf = http://dradio_mp3_dlf_m.akacast.akamaistream.net/7/249/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dlf_m
|
dlf = http://dradio_mp3_dlf_m.akacast.akamaistream.net/7/249/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dlf_m
|
||||||
|
|
Loading…
Reference in a new issue