From 18676401c228bfd48a6fc74c24f602e36a143bd2 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 4 May 2023 15:49:10 +0200 Subject: [PATCH] wait #5911 @0:20 --- src/Graphics/Color.php | 9 +++++++-- src/WebVideo.php | 44 +++++++----------------------------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/src/Graphics/Color.php b/src/Graphics/Color.php index 31fe8bd..0ac57c0 100644 --- a/src/Graphics/Color.php +++ b/src/Graphics/Color.php @@ -98,11 +98,12 @@ class Color } 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) { @@ -112,6 +113,10 @@ class Color $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); } diff --git a/src/WebVideo.php b/src/WebVideo.php index 28a668a..939c3cb 100644 --- a/src/WebVideo.php +++ b/src/WebVideo.php @@ -14,7 +14,7 @@ class WebVideo * @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); @@ -28,9 +28,11 @@ class WebVideo } else { $videoId = $res = $url; } - } else { + } else if ($searchMetadata) { $service = 'generic'; $videoId = $res = $url; + } else { + return false; } } @@ -105,32 +107,6 @@ class WebVideo 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; @@ -143,12 +119,6 @@ class WebVideo 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'; @@ -188,8 +158,8 @@ class WebVideo { $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'])) { @@ -231,7 +201,7 @@ class WebVideo 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) -- 2.39.5