fix hidden webp thumbnail throwing MIME type error in downloader #318
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'snativeImage
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:youtube-music/plugins/downloader/back.js
Lines 66 to 68 in 3485d26
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