New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetchart: Use the right filename extension according to the image's MIME type #2053
Comments
Wow! That's too bad. Is there a way we can reproduce this (i.e., can we fake fetching art for the album you have to get the same image)? |
Ha, it's hardly a troubling issue, but thought it was worth mentioning! The album in question was 9 by Damien Rice. If you grab that from fanarttv you'll see what I mean. Gnome image viewer wouldn't open it. Gimp opened it (I assume it ignores file types and goes by the file header instead) and when I checked it with the file command, it said it was a PNG. |
$ wget -q https://fanart.tv/detailpreview/fanart/music/2119beb8-6ac5-4f21-82a4-b831c90c0024/albumcover/9-4f31935ae2a25.jpg
$ file 9-4f31935ae2a25.jpg
9-4f31935ae2a25.jpg: PNG image data, 280 x 280, 8-bit/color RGB, non-interlaced Yep, certainly seems like an issue! Thanks @broddo 😄. |
That's the one. Sorry I should have provided you with the link. I'm half asleep here. |
Haha, no problem! 👍 @sampsyo Do we actually make an attempt at detecting the file type currently and converting if it's not a JPEG? |
Aha! We don't check the data itself, but we do check the MIME type that the server reports. Fortunately, it looks like fanart.tv doesn't lie there:
The trick is that our |
Assigning this to myself as a reminder, but I'll likely not tackle it until in a few weeks. So if anyone wants to step up, feel free to do so, no need to notify me. |
Unfortunately the files @jackwilsdon and @sampsyo mentioned are only the website previews, not the full-size images returned by the API, and for the latter fanart.tv does lie:
so the fix in #2068 will not solve your problem. On our side, this would need some |
What do you think of using python-magic, @wordofglass? The issue we have then is people need to install $ wget -q https://fanart.tv/fanart/music/2119beb8-6ac5-4f21-82a4-b831c90c0024/albumcover/9-4f31935ae2a25.jpg
$ python -c "import magic; print(magic.from_file('./9-4f31935ae2a25.jpg'))"
PNG image data, 1000 x 1000, 8-bit colormap, non-interlaced Admittedly we'd need to parse the magic type Another idea I just came up with is using the $ wget -q https://fanart.tv/fanart/music/2119beb8-6ac5-4f21-82a4-b831c90c0024/albumcover/9-4f31935ae2a25.jpg
$ identify -format "%m" 9-4f31935ae2a25.jpg
PNG |
I've already updated the PR (#2068) using the standard library |
Ah, I didn't realise you'd already sorted it out (the PR still says "EDIT: doesn't fix #2053, see there"). |
Updated the post ✨ |
This is something I noticed today when using fetchart with the fanarttv plugin - one random albumart file it downloaded was actually a PNG file, not a JPG. This wasn't fetchart's fault - I verified that the source image was indeed a PNG from fanarttv despite having the .jpg extension.
But, I think a nice feature would be to include some form of image validty check and perhaps offer to convert to the image to the desired default format.
The text was updated successfully, but these errors were encountered: