if query.path[:7] == '/embed/':
    return query.path.split('/')[2]
if query.path[:3] == '/v/':
    return query.path.split('/')[2]
return None
How can I extract video ID from YouTube's link in Python?