Spaces:
Runtime error
Runtime error
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 |