Skip to content

Instantly share code, notes, and snippets.

@manucabral
Created June 13, 2023 21:47
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 manucabral/484d5896b5f870f2a58df078b975b100 to your computer and use it in GitHub Desktop.
Save manucabral/484d5896b5f870f2a58df078b975b100 to your computer and use it in GitHub Desktop.
Get youtube video data using python.
import urllib3
import json
def get_data(embed_url: str) -> dict:
http = urllib3.PoolManager()
response = http.request("GET", embed_url)
return json.loads(response.data.decode("utf-8"))
if __name__ == "__main__":
video_url = input("Enter the video url: ")
embed_url = f"https://youtube.com/oembed?url={video_url}&format=json"
data = get_data(embed_url)
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment