src/Youtube.php
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);
        } elseif (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;
    }
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);
        } elseif (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;
    }
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 ) ; } elseif ( 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 ; }
Get the channel object by supplying the URL of the channel page

@param  string $youtube_url
@throws \Exception
@return object Channel object
Get the channel object by supplying the URL of the channel page