public function getChannelFromURL($youtube_url)
{
if (strpos($youtube_url, 'youtube.com') === false) {
throw new \Exception('The supplied URL does not look like a Youtube URL');
}
$path = static::_parse_url_path($youtube_url);
if (strpos($path, '/channel') === 0) {
$segments = explode('/', $path);
$channelId = $segments[count($segments) - 1];
$channel = $this->getChannelById($channelId);
} else {
if (strpos($path, '/user') === 0) {
$segments = explode('/', $path);
$username = $segments[count($segments) - 1];
$channel = $this->getChannelByName($username);
} else {
throw new \Exception('The supplied URL does not look like a Youtube Channel URL');
}
}
return $channel;
}