Skip to content

Instantly share code, notes, and snippets.

@eldoy
Created March 9, 2021 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldoy/3246f7efabe7a54ef9fefef8c08f9fdd to your computer and use it in GitHub Desktop.
Save eldoy/3246f7efabe7a54ef9fefef8c08f9fdd to your computer and use it in GitHub Desktop.

API v2 deprecated. New youtube api v3 works only with developer token and has limitation for free connections.

You can get JSON without API:

http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=ojCkgU5XGdg&format=json Or xml

http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=ojCkgU5XGdg&format=xml

Thumbs:

Sometimes we want use thumbnails from video. But max picture size depends on video resolution (SD or HD). This information absent in json response. To detect picture max size without api you need get 200 response from sddefault.jpg.

http://img.youtube.com/vi/ojCkgU5XGdg/sddefault.jpg if 404 use hqdefault.jpg instead. It has less quality but always exist and you can avoid 1 requests for detection it .

http://img.youtube.com/vi/ojCkgU5XGdg/hqdefault.jpg Or use max size

https://i.ytimg.com/vi/ojCkgU5XGdg/maxresdefault.jpg Mini thumbs:

http://img.youtube.com/vi/ojCkgU5XGdg/0.jpg http://img.youtube.com/vi/ojCkgU5XGdg/1.jpg http://img.youtube.com/vi/ojCkgU5XGdg/2.jpg http://img.youtube.com/vi/ojCkgU5XGdg/3.jpg Annotations

http://www.youtube.com/annotations_invideo?cap_hist=1&video_id=ojCkgU5XGdg parse mobile page 16kb

https://m.youtube.com/watch?v=ojCkgU5XGdg don't forget change user agent to iOS / Safari 7

also

http://www.youtube.com/get_video_info?html5=1&video_id=ojCkgU5XGdg also how embed youtube live

https://www.youtube.com/embed/live_stream?channel=UCkA21M22vGK9GtAvq3DvSlA Where UCkA21M22vGK9GtAvq3DvSlA is your channel id. You can find it inside youtube account on "My Channel" link.

Live thumb

https://i.ytimg.com/vi/W-fSCPrYSL8/hqdefault_live.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment