Added some checks for missing Targetfolder too many http requests and wrong urls.
Also changed the url of wdr3.
This commit is contained in:
parent
3498a8d00b
commit
9793b69715
2 changed files with 26 additions and 8 deletions
19
radiorec.py
19
radiorec.py
|
@ -106,12 +106,14 @@ def record_worker(stoprec, streamurl, target_dir, args):
|
||||||
while(not stoprec.is_set() and not conn.closed):
|
while(not stoprec.is_set() and not conn.closed):
|
||||||
target.write(conn.read(1024))
|
target.write(conn.read(1024))
|
||||||
|
|
||||||
|
|
||||||
verboseprint(print_time() + " ... Connection closed = " + str(conn.closed))
|
verboseprint(print_time() + " ... Connection closed = " + str(conn.closed))
|
||||||
conn.release_conn()
|
conn.release_conn()
|
||||||
|
|
||||||
def record(args):
|
def record(args):
|
||||||
settings = read_settings(args)
|
settings = read_settings(args)
|
||||||
streamurl = ''
|
streamurl = ''
|
||||||
|
tmpstr = ''
|
||||||
global verboseprint
|
global verboseprint
|
||||||
verboseprint = print if args.verbose else lambda *a, **k: None
|
verboseprint = print if args.verbose else lambda *a, **k: None
|
||||||
|
|
||||||
|
@ -123,15 +125,30 @@ def record(args):
|
||||||
if streamurl.endswith('.m3u'):
|
if streamurl.endswith('.m3u'):
|
||||||
verboseprint('Seems to be an M3U playlist. Trying to parse...')
|
verboseprint('Seems to be an M3U playlist. Trying to parse...')
|
||||||
pool = urllib3.PoolManager()
|
pool = urllib3.PoolManager()
|
||||||
|
try:
|
||||||
remotefile = pool.request('GET', streamurl)
|
remotefile = pool.request('GET', streamurl)
|
||||||
|
except MaxRetryError:
|
||||||
|
print('The URL of the station is not found! Check' + args.station + ' in the Settings!')
|
||||||
|
sys.exit()
|
||||||
|
if remotefile.status != 200:
|
||||||
|
print('The URL of the station is somehow faulty! Check' + args.station + ' in the Settings!')
|
||||||
|
sys.exit()
|
||||||
|
else:
|
||||||
for line in remotefile.data.decode().split():
|
for line in remotefile.data.decode().split():
|
||||||
if not line.startswith('#') and len(line) > 1:
|
if not line.startswith('#') and len(line) > 1 and line.endswith('mp3'):
|
||||||
tmpstr = line
|
tmpstr = line
|
||||||
break
|
break
|
||||||
|
if not len(tmpstr) > 1:
|
||||||
|
print('Could not find a mp3 stream')
|
||||||
|
sys.exit()
|
||||||
|
else:
|
||||||
streamurl = tmpstr
|
streamurl = tmpstr
|
||||||
|
|
||||||
verboseprint(print_time() + " ... Stream URL: " + streamurl)
|
verboseprint(print_time() + " ... Stream URL: " + streamurl)
|
||||||
target_dir = os.path.expandvars(settings['GLOBAL']['target_dir'])
|
target_dir = os.path.expandvars(settings['GLOBAL']['target_dir'])
|
||||||
|
if not os.path.isdir(target_dir + os.sep):
|
||||||
|
print('Target directory not found! Check that ' + target_dir + ' is a valid folder!')
|
||||||
|
sys.exit()
|
||||||
started_at = time.time()
|
started_at = time.time()
|
||||||
should_end_at = started_at + (args.duration * 60)
|
should_end_at = started_at + (args.duration * 60)
|
||||||
remaining = (args.duration * 60)
|
remaining = (args.duration * 60)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
[GLOBAL]
|
[GLOBAL]
|
||||||
target_dir = $HOME/Arbeitsfläche
|
#target_dir = $HOME/Arbeitsfläche
|
||||||
|
target_dir = $HOME/tmp
|
||||||
|
|
||||||
[STATIONS]
|
[STATIONS]
|
||||||
brklassik = http://streams.br-online.de/br-klassik_2.m3u
|
brklassik = http://streams.br-online.de/br-klassik_2.m3u
|
||||||
|
@ -10,5 +11,5 @@ erfplus = http://c14000-l.i.core.cdn.streamfarm.net/14000cina/live/3212erf_96/li
|
||||||
mdrklassik = http://avw.mdr.de/livestreams/mdr_klassik_live_128.m3u
|
mdrklassik = http://avw.mdr.de/livestreams/mdr_klassik_live_128.m3u
|
||||||
radioeins = http://www.radioeins.de/live.m3u
|
radioeins = http://www.radioeins.de/live.m3u
|
||||||
swr2 = http://mp3-live.swr.de/swr2_m.m3u
|
swr2 = http://mp3-live.swr.de/swr2_m.m3u
|
||||||
wdr3 = http://www.wdr.de/wdrlive/media/mp3/wdr3_hq.m3u
|
wdr3 = http://wdr-wdr3-live.icecast.wdr.de/wdr/wdr3/live/mp3/256/stream.mp3
|
||||||
ndrkultur = http://www.ndr.de/resources/metadaten/audio/m3u/ndrkultur.m3u
|
ndrkultur = http://www.ndr.de/resources/metadaten/audio/m3u/ndrkultur.m3u
|
||||||
|
|
Loading…
Reference in a new issue