jpdiazpardo's picture
Create youtube.py
4055a7e
raw
history blame
322 Bytes
from urllib.parse import parse_qs, urlparse
def get_youtube_video_id(url):
# Parse the URL using urlparse
parsed_url = urlparse(url)
# Extract the 'v' parameter from the query string
video_id = parse_qs(parsed_url.query).get('v')
if video_id:
return video_id[0]
else:
return None