modified the code to treat a file mutagen fails to load as a mp3
This commit is contained in:
parent
7c1bea379c
commit
26fad97915
|
@ -153,7 +153,13 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid
|
||||||
with tempfile.NamedTemporaryFile(mode ='wb+', delete=False) as audiofile:
|
with tempfile.NamedTemporaryFile(mode ='wb+', delete=False) as audiofile:
|
||||||
r.raw.decode_content = True
|
r.raw.decode_content = True
|
||||||
shutil.copyfileobj(r.raw, audiofile)
|
shutil.copyfileobj(r.raw, audiofile)
|
||||||
|
# mutagen should be able to guess the write file type
|
||||||
metadata_audiofile = mutagen.File(audiofile.name, easy=True)
|
metadata_audiofile = mutagen.File(audiofile.name, easy=True)
|
||||||
|
# if for some reason this should fail lets try it as a mp3 specific code
|
||||||
|
if metadata_audiofile == None:
|
||||||
|
logger.info('got a blank from mutagen')
|
||||||
|
metadata_audiofile = mutagen.mp3.MP3(audiofile.name, ID3=mutagen.easyid3.EasyID3)
|
||||||
|
logger.info('made a mp3')
|
||||||
#replace album title as needed
|
#replace album title as needed
|
||||||
metadata_audiofile = podcast_override_album(metadata_audiofile, podcast_name, album_override)
|
metadata_audiofile = podcast_override_album(metadata_audiofile, podcast_name, album_override)
|
||||||
metadata_audiofile.save()
|
metadata_audiofile.save()
|
||||||
|
|
Loading…
Reference in New Issue