} else if (preg_match('/hsv\(\s*(\d+)\s*,\s*(\d+)%?\s*,\s*(\d+)%?\s*\)/', $input, $matches)) {
$this->_processComposantes(self::HSVtoRGB($matches[1], $matches[2], $matches[3]));
} else {
- if (strlen($input) == 3) {
+ $len = strlen($input);
+ if ($len == 3) {
$c['red'] = str_repeat(substr($input, 0, 1), 2);
$c['green'] = str_repeat(substr($input, 1, 1), 2);
$c['blue'] = str_repeat(substr($input, 2, 1), 2);
- } else {
+ } else if ($len === 6 || $len === 8) {
if (strlen($input) == 6) {
$s = 0;
} elseif (strlen($input) >= 8) {
$c['red'] = substr($input, $s + 0, 2);
$c['green'] = substr($input, $s + 2, 2);
$c['blue'] = substr($input, $s + 4, 2);
+ } else {
+ $c['red'] = '00';
+ $c['green'] = '00';
+ $c['blue'] = '00';
}
$this->_processComposantes($c);
}
* @param $asArray bool
* @return mixed|string
*/
- public static function parse($url, bool $asArray = false)
+ public static function parse($url, bool $asArray = false, $searchMetadata = false)
{
if (self::_isParsed($url)) {
list($service, $videoId) = explode(':', $url);
} else {
$videoId = $res = $url;
}
- } else {
+ } else if ($searchMetadata) {
$service = 'generic';
$videoId = $res = $url;
+ } else {
+ return false;
}
}
return self::_getUrl($url, $options);
}
- public static function _getCnbcUrl($id, $options = array())
- {
- $url = 'http://player.cnbc.com/p/gZWlPC/cnbc_global?playertype=synd&byGuid=' . $id;
- return self::_getUrl($url, $options);
- }
-
- public static function _getKalturaUrl($id, $options = array())
- {
- $confid = $options['playerId'];
- $options['playerId'] = 'p_' . rand(1, 100000);
- $options['wid'] = $options['widgetId'] = '_' . $options['partnerId'];
-
- $url = 'http://cdnapi.kaltura.com/html5/html5lib/v1.6.12.40/mwEmbedFrame.php/p/' . $options['partnerId']
- . '/uiconf_id/' . $confid . '/entry_id/' . $id;
-
- return self::_getUrl($url, $options);
- }
-
- public static function _getDantubeUrl($id, $options = array())
- {
- $options['playerId'] = '10247951';
- $options['partnerId'] = '1073192';
- $options['widgetId'] = '1_d89zinhy';
- return self::_getKalturaUrl($id, $options);
- }
-
public static function _getDailymotionUrl($id, $options = array())
{
$url = 'https://www.dailymotion.com/embed/video/' . $id;
return self::_getUrl($url, $options);
}
- public static function _getCubetubeUrl($id, $options = array())
- {
- $url = 'https://extranet.cubedesigners.com/tools/tube';
- return self::_getUrl($url, $options);
- }
-
public static function _getFacebookUrl($id, $options)
{
$url = 'https://www.facebook.com/video/embed';
{
$r = Text::parseUrl($url);
if ($service == 'youtube') {
- if (isset($r['query_params']['v'])) {
- return $r['query_params']['v'];
+ if (preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user|shorts)\/))([^\?&\"'>]+)/", $url, $matches)) {
+ return $matches[1];
}
}
if (isset($r['query_params']['video'])) {
public static function _getServices()
{
- return array('youtube' => 'youtube', 'youtu.be' => 'youtube', 'dailymotion.com' => 'dailymotion', 'dai.ly' => 'dailymotion', 'vimeo.com' => 'vimeo', 'facebook.com' => 'facebook', 'cnbc.com' => 'cnbc');
+ return array('youtube' => 'youtube', 'youtu.be' => 'youtube', 'dailymotion.com' => 'dailymotion', 'dai.ly' => 'dailymotion', 'vimeo.com' => 'vimeo', 'facebook.com' => 'facebook');
}
public static function _isParsed($url)