]> _ Git - cubist_util.git/commitdiff
wait #5911 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 May 2023 13:49:10 +0000 (15:49 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 May 2023 13:49:10 +0000 (15:49 +0200)
src/Graphics/Color.php
src/WebVideo.php

index 31fe8bd562ab555900dc1d70e36532714b219369..0ac57c0ab4c7daf1a89089e5c38460400fb50acd 100644 (file)
@@ -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);
         }
index 28a668a991f6ce8f3cb8602e0bf366a532c1843c..939c3cbfae0630f861e0317e1a48dbe97c2112a7 100644 (file)
@@ -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)