Account for mutagen.File returning None for unreadable files#13
Account for mutagen.File returning None for unreadable files#13hedgepigdaniel wants to merge 1 commit intothebigmunch:develfrom
Conversation
|
Thanks for the contribution. Can you post a file (or a few) that The solution will likely be different than what you've proposed; I don't think I'd want to pass along a file whose type can't be detected properly. And, if I did, I'd want it to be an option defaulting to |
|
Sure. I did some further investigation and it came to my attention that the file... was literally empty. So to reproduce, just create an empty file and give it a supported extension. Seems like mutagen does it's own file type detection, which may (as in this case) conflict with the filetype detection that gmusicapi-wrapper does (based on extension, in get_supported_filepaths). http://mutagen.readthedocs.io/en/latest/api/base.html#mutagen.File |
|
The checking in I can't reproduce getting |
|
Just from quickly testing the other supported extensions, it looks like Ogg and MP4 don't throw an exception. This seems like something that should happen with mutagen. |
It seems to be possible for a file to be detected as a music file by gmusicapi-wrapper but for mutagen to detect it as a non music file. This results in mutagen.File returning None which eventually is treated as a dictionary, causing an unhandled exception.
This change checks the return value of mutagen.File and handles None similarly to how exceptions are currently handled (filename is logged and added to the filtered files list).