Skip to content
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

fix hidden webp thumbnail throwing MIME type error in downloader #318

Merged
merged 2 commits into from
Jun 19, 2021

Conversation

Araxeus
Copy link
Collaborator

@Araxeus Araxeus commented Jun 9, 2021

Fix #315

The Problem

youtube sometimes hide the real picture filetype, for example in this link:

https://i.ytimg.com/vi/tmntIJSf0Dw/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLC5b9hkS4_861N7ooUq4fUGX7RLCw

the .jpg is a lie, this file is a webp - and Electron's nativeImage doesn't support this type.
(when trying to save the picture in a browser, it will auto suggest name hqdefault.jpg.webp..)

this results in an empty native image - and setting APIC frame to an empty buffer:

writer.setFrame("APIC", {
type: 3,
data: coverBuffer,

results in a thrown error: Unknown picture MIME type

The Fix

fixed by removing everything that comes after the ".jpg" (only if needed - the nativeImage is empty)
in our example the result is:
https://i.ytimg.com/vi/tmntIJSf0Dw/hqdefault.jpg
which is a valid jpg file

Also check before creating coverBuffer that nativeImage isn't empty to avoid potential error throwing

@Araxeus Araxeus changed the title fix unsupported hidden webp coverart fix hidden webp thumbnail throwing MIME type error in downloader Jun 9, 2021
Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the fix!

@th-ch th-ch merged commit e0cb132 into th-ch:master Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Unknown picture MIME type
2 participants