public function getVideoInfo($url)
    {
        if (!empty($url)) {
            if (strpos($url, 'youtube')) {
                preg_match('/(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/', $url, $v);
                $provider = 'youtube';
                $url_data = sprintf($this->_youtubeVideoApi, $v[0]);
            } elseif (strpos($url, 'vimeo')) {
                preg_match('(\d+)', $url, $id);
                $provider = 'vimeo';
                $url_data = sprintf($this->_vimeoVideoApi, $id[0]);
            }

            switch ($provider) {
                case 'youtube':
                    $ch = curl_init($url_data);  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/json')); 
                    $result = json_decode(curl_exec($ch), true);
                    curl_close($ch);

                    return array(
                        'title'       => $result['entry']['title']['$t'],
                        'description' => $result['entry']['media$group']['media$description']['$t'],
                        'thumbnail'   => $result['entry']['media$group']['media$thumbnail'][0]['url'],
                        'duration'    => $result['entry']['media$group']['media$content'][0]['duration'],
                        'upload_date' => $result['entry']['media$group']['yt$uploaded']['$t'],
                    );
                    break;

                case 'vimeo':
                    $ch = curl_init($url_data);  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/json')); 
                    $result = json_decode(curl_exec($ch), true);
                    curl_close($ch);

                    return array(
                        'title'       => $result[0]['title'],
                        'description' => $result[0]['description'],
                        'thumbnail'   => $result[0]['thumbnail_small'],
                        'duration'    => $result[0]['duration'],
                        'upload_date' => $result[0]['upload_date']
                    );
                    break;
                
                default:
                    return false;
                    break;
            }
        }
        return false;
    }