Merge pull request #669 from Robbt/fix-mp3-mutagen-non-detect
modified the code to treat a file mutagen fails to load as a mp3
This commit is contained in:
commit
8dd55e24fe
|
@ -153,8 +153,16 @@ def podcast_download(id, url, callback_url, api_key, podcast_name, album_overrid
|
|||
with tempfile.NamedTemporaryFile(mode ='wb+', delete=False) as audiofile:
|
||||
r.raw.decode_content = True
|
||||
shutil.copyfileobj(r.raw, audiofile)
|
||||
# mutagen should be able to guess the write file type
|
||||
metadata_audiofile = mutagen.File(audiofile.name, easy=True)
|
||||
# replace album title as needed
|
||||
# if for some reason this should fail lets try it as a mp3 specific code
|
||||
if metadata_audiofile == None:
|
||||
# if this happens then mutagen couldn't guess what type of file it is
|
||||
mp3suffix = ("mp3", "MP3", "Mp3", "mP3")
|
||||
# so we treat it like a mp3 if it has a mp3 file extension and hope for the best
|
||||
if filename.endswith(mp3suffix):
|
||||
metadata_audiofile = mutagen.mp3.MP3(audiofile.name, ID3=mutagen.easyid3.EasyID3)
|
||||
#replace album title as needed
|
||||
metadata_audiofile = podcast_override_album(metadata_audiofile, podcast_name, album_override)
|
||||
metadata_audiofile.save()
|
||||
filetypeinfo = metadata_audiofile.pprint()
|
||||
|
|
Loading…
Reference in New Issue