Iwaslazkis / browser-playerctl

:headphones: Implements MPRIS interface for chrome
1 stars 0 forks source link

Get highest resolution possible thumbnail #1

Open Iwaslazkis opened 2 years ago

Iwaslazkis commented 2 years ago

Currently, the extension only looks for the HQ quality thumbnail:

https://github.com/Iwaslazkis/browser-playerctl/blob/ac63dc7cf586868b8e8f5a5c28d7d26e6bb36cd2/extension/providers/youtube.js#L56

Some videos don't have a thumbnail at that quality, and others have better quality thumbnails. It'd be nice to pick out the highest quality one possible.

Iwaslazkis commented 2 years ago

It seems that i.ytimg.com returns a 404 status code along with a grey box image when the corresponding thumbnail resolution doesn't exist; perhaps we can have the browser query the each possible resolution in descending order and take whichever one return a 200 status code first?

Iwaslazkis commented 2 years ago

From this short article, it seems that these are all the available resoltutions for the thumbnail:

  1. https://i.ytimg.com/vi/<video_id>/default.jpg Dimensions: 120x90 This is the default resolution (lowest available).

  2. https://i.ytimg.com/vi/<video_id>/mqdefault.jpg Dimensions: 320x180 This is called a medium size thumbnail.

  3. https://i.ytimg.com/vi/<video_id>/hqdefault.jpg Dimensions: 480x360 This is called a high size thumbnail.

  4. https://i.ytimg.com/vi/<video_id>/sddefault.jpg Dimensions: 640x480 This is called a standard size thumbnail.

  5. https://i.ytimg.com/vi/<video_id>/maxresdefault.jpg Dimensions: 1280x720 This is the maximum resolution available.