Retrieves the provider of the embed url
@param - $url: the url of the "player"
@return - string
@todo - do some real world testing.
490727
public function getProviderName($url) {
        return Template::raw(VideoEmbedder::$plugin->service->getInfo($url)->providerName);
    }
600115
protected function getUrlContent($url)
    {
        $contents = '';
        $time = (int) self::MAX_TIMEOUT_MINS * 60;

        $timeout = stream_context_create(array(
            'http' => array(
                'timeout' => $time,
            ),
        ));
        set_time_limit($time);
        ini_set('max_execution_time', $time);

        // check if the URL is valid
        if($this->isValidUrl($url)) {
            // make sure we are not getting 404 when accessing the page
            if( (int) $this->getUrlStatus($url) != self::HTTP_NOT_OK ) {
                // ge the contents of the page
                $contents = @file_get_contents($url, false, $timeout);

                // if the contents has results
                if($contents === true) {
                    // convert encodings
                    $contents = mb_convert_encoding($contents, 'HTML-ENTITIES', self::ENCODING);
                }
            }
        }



        return $contents;
    }
848710
public static function getHostFromUrl($url)
    {
        $parsedUrl = parse_url($url);

        if (empty($parsedUrl['host'])) {
            return;
        }

        return Common::mb_strtolower($parsedUrl['host']);
    }
256400
public function buildUrl(string $url): string
    {
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            return $url;
        }
        return $this->endPoint . static::ENDPOINT_SUFFIX . $url;
    }
514654
protected static function parseUrl($url)
    {
        $url_parts = Utils::multibyteParseUrl($url);

        if (isset($url_parts['scheme'])) {
            /** @var UniformResourceLocator $locator */
            $locator = Grav::instance()['locator'];

            // Special handling for the streams.
            if ($locator->schemeExists($url_parts['scheme'])) {
                if (isset($url_parts['host'])) {
                    // Merge host and path into a path.
                    $url_parts['path'] = $url_parts['host'] . (isset($url_parts['path']) ? '/' . $url_parts['path'] : '');
                    unset($url_parts['host']);
                }

                $url_parts['stream'] = true;
            }
        }

        return $url_parts;
    }
475216
public function generateUrl($url)
    {
        $extern = false;
        if ((0 === strrpos($url, 'http://'))
            || (0 === strrpos($url, 'https://'))) {
            $extern = true;
        }

        $http = (isset($_SERVER['HTTPS'])) ? 'https://' : 'http://';

        if (!$extern) {
            return ($this->getRoot() == '/')
                ? (($this->getRoot() == $url) ? '' : $url) : $http.$_SERVER['SERVER_NAME'].$this->getRoot().$url;
        } else {
            return $url;
        }
    }
1139120
public function getEmbedUrl($url, $params = [] )
    {
        // looks like there are, now let's only do this for YouTube and Vimeo
        if($this->getInfo($url)->type == 'video' && ($this->isYouTube($url) || $this->isVimeo($url)))
        {
            $parameters = '';

            // check if theree are any parameters passed along
            if (!empty($params)) {
                
                $parameters .= '?';
                $i = 0;
                foreach ($params as $k=>$v) {
                    if (($parameters !== null) && ($i !== 0)) {
                        $parameters .= '&';
                    }
                    $parameters .= "{$k}={$v}";
                    $i++;
                }
            }
            
            if ($this->isYouTube($url)) {
                $id = $this->getYouTubeId($url);
    
                $embedUrl = '//www.youtube.com/embed/' . $id . $parameters;
                return $embedUrl;
            } else if ($this->isVimeo($url)) {
                $id = $this->getVimeoId($url);
    
                $embedUrl = '//player.vimeo.com/video/' . $id . $parameters;
                return $embedUrl;
            }
        }
        else
        {
            // return empty string
            return '';
        }
    }
70235
private function getUrlGenerator($sourceUrl)
    {
        foreach ($this->urlGenerators as $urlGenerator) {
            if ($urlGenerator->supports($sourceUrl)) {
                return $urlGenerator;
            }
        }

        return null;
    }
296043
protected function _getProVideo($url) {
        $vimeoVars = $this->_getVimeoConfig();
        $vimeo = new Garp_Service_Vimeo_Pro($vimeoVars->consumerKey, $vimeoVars->consumerSecret);
        $this->_setVimeoAccessToken($vimeo);

        // check if a Vimeo URL is given
        $pattern = '~vimeo.com/(?:video/)?([0-9]+)~';
        preg_match($pattern, $url, $matches);
        if (!isset($matches[1])) {
            throw new Garp_Model_Behavior_Exception(self::EXCEPTION_MISSING_VIMEO_ID);
        }
        $videoId = $matches[1];
        $video = $vimeo->videos->getInfo($videoId);
        return $video[0];
    }
829119
protected function getUrlContents($url)
    {
        $client = $this->getGuzzleClient();

        return $client->get($url)->getBody()->getContents();
    }
87464
public function embedCodeFor(string $url)
    {
        if (!$parsedUrl = $this->embedder->parseUrl($url)) {
            return null;
        }

        return $parsedUrl->getEmbedCode();
    }
303390
function formatUrl($url)
    {
        if (! $this->isUrl($url)) {
            return null;
        }
        $url = trim($url);
        $url = str_replace(' ', '+', $url);
        $parse = parse_url($url);
        strtolower($parse['scheme']);
        strtolower($parse['host']);
        return $this->buildUrl($parse);
    }
1189820
public function url($url)
    {
        if (is_string($url)) {
            $url = $this->localePrefix($url);
        }

        try {
            $url = Router::url($url, true);
        } catch (\Exception $ex) {
            $url = '';
        }

        return $url;
    }
1090429
protected function getHost($url)
    {
        $data = parse_url($url);
        if (empty($data['host'])) {
            throw new \InvalidArgumentException('The Url: ' . $url . ' seems to be invalid');
        }

        $host = preg_replace('~^(?:www|player)\.~i', '', strtolower($data['host']));
        if (isset($this->services[$host])) {
            return $host;
        } else if (isset($this->services['*.' . $host])) {
            return '*.' . $host;
        } else if (!empty($this->wildCardHosts)) {
            $trans = array('\*' => '(?:.*)');
            foreach ($this->wildCardHosts as $value) {
                $regex = strtr(preg_quote($value, '~'), $trans);
                if (preg_match('~' . $regex . '~i', $host)) {
                    return $value;
                }
            }
        }

        return $host;
    }
927757
public static function getRequestClientIP($url='')
    {
        if (!$url || !is_string($url)){
            if (isset($_SERVER['REMOTE_ADDR']))
                $url = $_SERVER['REMOTE_ADDR'];
        }
        return (filter_var($url, FILTER_VALIDATE_IP)) ? $url : '';
    }
422970
private function getHostFromUrl($url)
    {
        if (strpos($url, '//')) {
            $url = substr($url, strpos($url, '//') + 2);
        }
        if (($p = strpos($url, '/')) !== false) {
            $url = substr($url, 0, $p);
        }
        return $url;
    }
424505
private function generateUrl($url)
    {
        if ($this->packages) {
            return $this->packages->getUrl($url);
        }

        if ($this->coreAssetsHelper) {
            // To remove when compatibility with Symfony 2.7 is dropped
            return $this->coreAssetsHelper->getUrl($url);
        }

        return $url;
    }