Parses a YouTube url and returns the YouTube ID
@param string $url Video url
@return mixed Youtube ID or `false`
171439
public static function getId($url)
    {
        if (strpos($url, 'youtube.com') !== false) {
            $url = parse_url($url);

            if (empty($url['query'])) {
                return false;
            }

            parse_str($url['query'], $url);

            return empty($url['v']) ? false : $url['v'];
        }

        if (preg_match('/youtu\.be\/([^?]+)/', $url, $matches)) {
            return $matches[1];
        }

        return false;
    }
540478
protected function getUrlContents(string $url): string
    {
        $request = $this->getRequest($url);

        return $this->getParsedResponse($request);
    }
658743
function ParseUrl($url) {
	    $content = null;

    	$this->Clear();

		$this->url = htmlspecialchars_decode($url);

	    ob_start();
	    if (function_exists('curl_init')) {
		    //curl is the preferred function
		    $crl = curl_init();
		    curl_setopt($crl, CURLOPT_URL, $url);
		    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
		    curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
		    curl_setopt($crl, CURLOPT_TIMEOUT, 20);
		    $FileData = curl_exec($crl);
		    $FileInfo = curl_getinfo($crl);
		    curl_close($crl);
		    if ($FileInfo['http_code'] != 200) {
			    throw new \HttpRequestException($FileInfo['http_code'] . ' error for file: ' . $url);
		    }
	    } else {
		    //see if we can use fopen to get file
		    $fopen_check = ini_get('allow_url_fopen');
		    if (!empty($fopen_check)) {
			    $content = file_get_contents($url);
		    } else {
			    throw new \RuntimeException('CURL_DISABLED');
		    }
	    }
	    ob_end_clean();

		if(strlen($content)) {
			$this->modifyContent($content);
			$this->ParseStr($content);
			return true;
		} else {
			return false;
		}
	}
711087
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;
    }
873548
public function parseURL($url)
	{
		try {
			$u = parse_url($url);
			if(isset($u["query"]))
	        	$this->parseQueryString($u["query"]);
	        if(isset($u["fragment"]))
	        	$this->parseQueryString($u["fragment"]);
	    } catch (Exception $e) {
	    } 
	}
438649
private function parseLink()
    {
        $value = $this->RAW();

        if (!$value) {
            return false;
        }

        $output = false;

        if (preg_match(
            '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/i',
            $value,
            $matches
        )) {
            foreach ($matches as $match) {
                if (preg_match('/^[0-9]{6,12}$/', $match)) {
                    $output = [
                        'VideoID'      => $match,
                        'VideoService' => 'Vimeo',
                    ];
                }
            }
        } elseif (preg_match('/https?:\/\/youtu\.be\/([a-z0-9\_\-]+)/i', $value, $matches)) {
            $output = [
                'VideoID'      => $matches[1],
                'VideoService' => 'YouTube',
            ];
        } elseif (preg_match('/youtu\.?be/i', $value)) {
            $query_string = [];
            parse_str(parse_url($value, PHP_URL_QUERY), $query_string);
            if (!empty($query_string['v'])) {
                $output = [
                    'VideoID'      => $query_string['v'],
                    'VideoService' => 'YouTube',
                ];
            }
        }

        return ($output) ? $output : false;
    }
943061
public function extractYoutubeId($sUrl)
    {
        preg_match('/^https?\:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_\-]+)$/', $sUrl, $aMatches);

        if (!empty($aMatches[1])) {

            return $aMatches[1];

        } else {

            preg_match('/^https?\:\/\/youtu\.be\/([a-zA-Z0-9_\-]+)$/', $sUrl, $aMatches);

            if (!empty($aMatches[1])) {

                return $aMatches[1];
            }
        }

        return null;
    }
844157
public function getData($url)
    {
        $json = null;

        if(extension_loaded('curl'))
        {
            $ch = curl_init(str_replace('{id}', $this->id, $url));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $json = curl_exec($ch);
        }
        else
        {
            $json = @file_get_contents(str_replace('{id}', $this->id, $url));
        }

        if(!$json)
        {
            throw new \Exception("Video or channel id is not found");
        }

        return $this->parseData($json);
    }
86211
protected static function parseUrl($url)
    {
        $components = @parse_url($url);
        if (! empty($components)) {
            return $components;
        }

        if (is_null(static::$is_parse_url_bugged)) {
            static::$is_parse_url_bugged = ! is_array(@parse_url("//example.org:80"));
        }

        //bugfix for https://bugs.php.net/bug.php?id=68917
        if (static::$is_parse_url_bugged &&
            strpos($url, '/') === 0 &&
            is_array($components = @parse_url('http:'.$url))
        ) {
            unset($components['scheme']);
            return $components;
        }
        throw new RuntimeException(sprintf("The given URL: `%s` could not be parse", $url));
    }
74183
public function parseVIdFromURL($vimeo_url)
    {
        if (strpos($vimeo_url, 'vimeo.com')) {
            $tokens = explode("/", $vimeo_url);
            if(is_numeric($tokens[3]))
                return $tokens[3];
            else
                throw new \Exception('The supplied URL does not contain a valid Vimeo video id');
        } else {
            throw new \Exception('The supplied URL does not look like a Vimeo URL');
        }
    }
1036074
public function parse($url)
    {
        $this->_fixUrlForParsing($url);

        if (empty($url->path) && !isset($url->query['option'])) {
            $url->path = (get_viewer()->guest()) ? 'pages' : 'dashboard';
        }

        $segments = explode('/', trim($url->path, '/'));
        $segments = array_filter($segments);

        if (!empty($segments)) {
            $component = array_shift($segments);
            $url->query = array_merge(array('option' => 'com_'.$component), $url->query);
            $component = str_replace('com_', '', $url->query['option']);
            $query = $this->getComponentRouter($component)->parse($segments);
            $url->query = array_merge($url->query, array('option' => 'com_'.$component), $query);
        }

        return $url;
    }
1310234
public function api_get($url, $params)
    {
        //set the youtube key
        $params['key'] = $this->youtube_key;

        //boilerplates for CURL
        $tuCurl = curl_init();
        curl_setopt($tuCurl, CURLOPT_URL, $url . (strpos($url, '?') === false ? '?' : '') . http_build_query($params));
        if (strpos($url, 'https') === false) {
            curl_setopt($tuCurl, CURLOPT_PORT, 80);
        } else {
            curl_setopt($tuCurl, CURLOPT_PORT, 443);
        }

        curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
        $tuData = curl_exec($tuCurl);
        if (curl_errno($tuCurl)) {
            throw new \Exception('Curl Error : ' . curl_error($tuCurl));
        }

        return $tuData;
    }
99661
public static function params($url) {
        $path  = explode('?', $url)[0];
        $query = parse_url($url, PHP_URL_QUERY);
        if ($query) {
            return site_url($path, $query);
        } else {
            return false;
        }
    }
1061603
public function parse($url)
    {
        $content = $this->performRequest($url)->getBody()->getContents();

        $content = $this->convertEncodingToUTF8($content);

        return $this->getHtmlDomParser($content);
    }
989552
protected function parseURL($url)
    {
        $parsed = parse_url($url);
        if ($parsed === false) {
            return false;
        } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
            return false;
        } else {
            if (!isset($parsed['host']) || !$this->isValidHostName($parsed['host'])) {
                return false;
            } else {
                if (!isset($parsed['port'])) {
                    $parsed['port'] = getservbyname($parsed['scheme'], 'tcp');
                    if (!is_int($parsed['port'])) {
                        return false;
                    }
                }
            }
        }
        $parsed['custom'] = (isset($parsed['path']) ? $parsed['path'] : '/') . (isset($parsed['query']) ? '?' . $parsed['query'] : '');
        return $parsed;
    }
1319219
protected function getIdFromUrl($url)
    {
        $fileName = basename($url);
        $idParts = explode('-', $fileName);

        if (count($idParts) < 2) {
            throw new ImageProxyInvalidUrl('No `id` was found in the url');
        }

        $id = $idParts[0];

        if (preg_match('/[^0-9]/', $id)) {
            throw new ImageProxyInvalidUrl('The founded `id` was not a valid integer');
        }

        return $id;
    }
1348129
private function parseUrl($url)
    {
        $parsed = parse_url($url);

        if ((count($parsed) === 1)
            && isset($parsed['path'])
            && (0 === strpos($parsed['path'], '?') || false !== strpos($parsed['path'], '&'))
        ) {
            $parsed = array(
                'query' => $parsed['path']
            );

            return $parsed;
        }

        return $parsed;
    }