Python Youtube Oembed

Mar 27, 2020
import requestsfrom urllib.parse import urlencodeurl = ''query_string = urlencode({'url': url, 'format': 'json'})oembed_url = f"{query_string}"r = requests.get(oembed_url)if r.status_code == 200:    result = r.json()    html = result['html'].strip()
   "title":"How we must respond to the COVID-19 pandemic | Bill Gates",
   "html":"\u003ciframe width=\"480\" height=\"270\" src=\"https:\/\/\/embed\/Xe8fIjxicoo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\u003c\/iframe\u003e",

NOTE: Just embed the html and the player will load without additional javascript required.


❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.