-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Embedart: fails on some jpegs because imghdr doesn't recognize the mimetype #1545
Conversation
detect jpeg files using their magic bytes following the unix file implementation by adding a test function to the imghdr.tests list, as intended
I added a commit to fix the code style issues. |
Awesome! Thanks for sorting this out. Looks great so far.
|
|
I added a commit re:testing. The test now passes and fails adequately. |
Nice! The test looks great. Would you mind adding a comment to the code with that link? Could help us stay less confused later on. 😃 |
I added two commits with a more elegant implementation which doesn't require to modify Should I try to build a smaller image which fits the edge case or is the 1000x1000 image acceptable in the test ressources? |
This is looking great. Thanks for the extra comments. A smaller image would be wonderful if it's not too difficult -- it seems a little suboptimal to add a 0.5 MB file to the beets distribution for just one test. (And avoiding copyrighted images is also a plus.) |
Yeah I don't know I never tried but I guess it shouldn't be too difficult :) |
I added a commit with a smaller test image. Anything else to be done? |
Do I need to do anything else before this can be merged? |
Nope, I was just being slow. Thanks for your patience. |
Embedart: fails on some jpegs because imghdr doesn't recognize the mimetype
All merged up! Thank you again! ✨ |
Thank you very much for your responsiveness 😃 |
Apply #1545 to a public function used everywhere
Apply #1545 to a public function used everywhere
This errors pops up
with this cover (found by beets-fetchart).
This is due to this issue. Fortunately,
imghdr
provides the listimghdr.tests
to add extra mimetype tests. I added a test which identifies jpeg files based on their magic bytes, which is the method used byfile
.This is my first time contributing to beets, so I think some code style guidance is probably needed (mainly regarding the modification of
imghdr.tests
, which should only happen once). I also absolutely need some help with adding the right tests. There is some testing code in this PR, which is very naively based on the rest oftest_mediafile.py
, but the test doesn't fail without the patch, and I think it actually never runs. I should probably also find/build a smaller cover which can only be recognized based on the magic bytes.