Created
June 13, 2023 21:47
-
-
Save manucabral/484d5896b5f870f2a58df078b975b100 to your computer and use it in GitHub Desktop.
Get youtube video data using python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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