[youtube] `maxresdefault` doesn't exist sometimes
See original GitHub issueOriginally posted by @Zirro here
I’ve received several 404’s for maxresdefault
URLs with this change, so unfortunately it doesn’t seem to be true for every video. The best approach would probably be to initially request maxresdefault
and look at the response code. If it’s 404, try with hqdefault
instead.
It could also be worth using a similar approach to check for the existence of a .webp
-version of the thumbnail at the /vi_webp/
-path before falling back to the .jpgˋ-version
, though the difference in quality doesn’t seem to be very significant here.
Here’s one where there is no maxresdefault
size at all: https://www.youtube.com/watch?v=pS4ca4GB-_c
https://i.ytimg.com/vi/pS4ca4GB-_c/maxresdefault.jpg (404) https://i.ytimg.com/vi_webp/pS4ca4GB-_c/maxresdefault.webp (404)
Here’s one where both JPEG and WebP-files are accessible at separate URLs: https://www.youtube.com/watch?v=goSEyGNfiPM
https://i.ytimg.com/vi/goSEyGNfiPM/maxresdefault.jpg (200) https://i.ytimg.com/vi_webp/goSEyGNfiPM/maxresdefault.webp (200)
Here’s one where only the JPEG-file is available: https://www.youtube.com/watch?v=xp-b4Ce4Mf4
https://i.ytimg.com/vi/xp-b4Ce4Mf4/maxresdefault.jpg (200) https://i.ytimg.com/vi_webp/xp-b4Ce4Mf4/maxresdefault.webp (404)
I’m not sure if there are cases where only the WebP exists, though. Besides that it’s mainly a question of whether checking for the .webp
first should be done for the theoretical quality improvement, with the .jpg
staying as fallback when there is no WebP available.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
the thumbnail shown in embed is normally the highest resolution one. So I opened
https://www.youtube.com/embed/pS4ca4GB-_c
and checked the network requestsI don’t know why I didn’t think of this before. I can just put the best “known” thumbnail as
thumbnail
while still populatingthumbnails
with all possible thumbnails.Then
--get-thumbnail
will give you a correct (but not the best) thumbnail without needing to check all the URLs while--write-thumbnail
(due to it’s in-build fallback logic) always gives the best quality thumbnail.If anyone wants to get the best thumbnail URL and don’t mind the slowdown, they can use
--print %(thumbnails.-1.url)s --check-all-formats