Spaces:
Runtime error
Runtime error
File size: 322 Bytes
b8a333c |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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 |