Commit 6f740f6b authored by Bernhard Geier's avatar Bernhard Geier

Workaround for negative chapter starts and chapters exceeding file duration

parent 4c5188b6
# FM4 7-Tage Backup
# FM4 7-Tage Download
The Austrian radio station FM4 publishes MP3 recordings of all of their shows during the last 7 days on its website.
This Python 3 script is a simple command line tool to download all currently available recordings for a specific show.
......@@ -178,11 +178,21 @@ for hit in result['hits']:
if item[key] is not None:
# For multipart shows sometimes chapters start in the previous part
# As in ID3 chapter start times must not be negative set chapter start to 0 in that case
chapterStart = item['start'] - broadcastJson['streams'][streamNr]['start']
if chapterStart < 0:
chapterStart = 0
chapterEnd = item['end'] - broadcastJson['streams'][streamNr]['start'] # FIXME: chapters (and shows?) seem to be 1s too long
if chapterEnd > broadcastJson['streams'][streamNr]['end'] - broadcastJson['streams'][streamNr]['start']:
chapterEnd = broadcastJson['streams'][streamNr]['end'] - broadcastJson['streams'][streamNr]['start']
"id": "ch"+str(chapterNr),
"title": " / ".join(chapterTitle),
"startTime": item['start']-broadcastJson['streams'][streamNr]['start'],
"endTime": item['end']-broadcastJson['streams'][streamNr]['start'] # FIXME: chapters (and shows?) seem to be 1s too long
"startTime": chapterStart,
"endTime": chapterEnd,
for c in chapters:
......@@ -193,7 +203,6 @@ for hit in result['hits']:
sub_frames = [TIT2(text=[c["title"]])]
tocList = ",".join([ c["id"] for c in chapters ])
element_id = "toc",
......@@ -213,7 +222,6 @@ for hit in result['hits']:
# save ID3 tags".part",v2_version=3)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment