public static function parseVIdFromURL($youtube_url)
{
$videoId = null;
if (strpos($youtube_url, 'youtube.com')) {
if (strpos($youtube_url, 'embed')) {
$path = static::_parse_url_path($youtube_url);
$videoId = substr($path, 7);
}
if ($params = static::_parse_url_query($youtube_url)) {
$videoId = isset($params['v']) ? $params['v'] : null;
}
} else {
if (strpos($youtube_url, 'youtu.be')) {
$path = static::_parse_url_path($youtube_url);
$videoId = substr($path, 1);
}
}
if (empty($videoId)) {
throw new \Exception('The supplied URL does not look like a Youtube URL');
}
return $videoId;
}