Nothing noteworthy.

This commit is contained in:
Martin Brodbeck 2013-09-13 13:51:01 +02:00
parent 548145d530
commit fa69b264be

View file

@ -9,7 +9,6 @@ with "at" or "crontab".
import argparse import argparse
import configparser import configparser
import threading import threading
import time
import urllib.request import urllib.request
def _check_args(): def _check_args():
@ -35,14 +34,17 @@ def _check_duration(value):
return value return value
def record(stoprec): def record(stoprec):
while(not stoprec.is_set()): target = open('./test.mp3', "wb")
time.sleep(1) conn = urllib.request.urlopen('http://dradio_mp3_dlf_m.akacast.akamaistream.net/7/249/142684/v1/gnl.akacast.akamaistream.net/dradio_mp3_dlf_m')
#print(conn.getheader('Content-Type'))
while(not stoprec.is_set() and not conn.closed):
target.write(conn.read(1024))
def main(): def main():
args = _check_args() args = _check_args()
stoprec = threading.Event() stoprec = threading.Event()
recthread = threading.Thread(target=record, args=(stoprec,)) recthread = threading.Thread(target = record, args = (stoprec,), daemon = True)
recthread.start() recthread.start()
recthread.join(args.duration * 60) recthread.join(args.duration * 60)
if(recthread.is_alive): if(recthread.is_alive):