Browse Source

Merge branch 'stable/v0.8' into feature/v0.8/addelement

Sevajol Bastien 12 years ago
parent
commit
8b26c255e6

+ 2 - 2
src/Muzich/CoreBundle/Factory/Elements/Dailymotioncom.php View File

@@ -23,7 +23,7 @@ class Dailymotioncom extends ElementFactory
23 23
     $ref_id = null;
24 24
     
25 25
     // Récupération de l'id
26
-    if (preg_match("#(video\/)([a-zA-Z0-9]+)([a-zA-Z0-9_-]*)#", $url_clean, $preg_result))
26
+    if (preg_match("#\/(video\/)([a-zA-Z0-9]+)([a-zA-Z0-9_-]*)#", $url_clean, $preg_result))
27 27
     {
28 28
       $ref_id = $preg_result[2];
29 29
       $this->element->setData(Element::DATA_REF_ID, $ref_id);
@@ -42,7 +42,7 @@ class Dailymotioncom extends ElementFactory
42 42
       
43 43
       curl_setopt_array($api_url, $options);
44 44
       $api_result = json_decode(curl_exec($api_url));
45
-      
45
+            
46 46
       // On récupère l'url du thumbnail
47 47
       if (isset($api_result->thumbnail_medium_url))
48 48
       {

+ 12 - 2
src/Muzich/CoreBundle/Factory/Elements/Soundcloudcom.php View File

@@ -61,10 +61,20 @@ class Soundcloudcom extends ElementFactory
61 61
       {
62 62
         if (count($result->errors))
63 63
         {
64
-          return null;
64
+          return;  
65 65
         }
66 66
       }
67
-
67
+      
68
+      if (!isset($result->location))
69
+      {
70
+        return;
71
+      }
72
+      
73
+      if (!$result->location)
74
+      {
75
+        return;
76
+      }
77
+      
68 78
       $getjsonurl = $result->location;
69 79
       // On a maintenant la bonne url pour demander les infos
70 80
       $ch = curl_init($getjsonurl);

+ 16 - 4
src/Muzich/CoreBundle/Factory/Elements/Youtubecom.php View File

@@ -16,11 +16,23 @@ class Youtubecom extends ElementFactory
16 16
   protected function proceedAPIDatas($ref_id)
17 17
   {
18 18
     $video_data_dom = new \DOMDocument;
19
-    $video_data_dom->load("http://gdata.youtube.com/feeds/api/videos/". $ref_id);
20
-    
21
-    if (($title = $video_data_dom->getElementsByTagName("title")->item(0)->nodeValue))
19
+    try {
20
+      $video_data_dom->load("http://gdata.youtube.com/feeds/api/videos/". $ref_id);
21
+
22
+      if ($video_data_dom->getElementsByTagName("title"))
23
+      {
24
+        if ($video_data_dom->getElementsByTagName("title")->item(0))
25
+        {
26
+          if (($title = $video_data_dom->getElementsByTagName("title")->item(0)->nodeValue))
27
+          {
28
+            $this->element->setData(Element::DATA_TITLE, $title);
29
+          }
30
+        }
31
+      }
32
+    }
33
+    catch (\ErrorException $e)
22 34
     {
23
-      $this->element->setData(Element::DATA_TITLE, $title);
35
+      // Api injoignable
24 36
     }
25 37
   }
26 38
   

+ 2 - 2
src/Muzich/CoreBundle/Tests/ElementFactory/ElementFactoryTest.php View File

@@ -353,7 +353,7 @@ class ElementFactoryTest extends UnitTest
353 353
     $this->assertEquals(array(
354 354
       'data_ref_id' => 3770,
355 355
       'data_title' => 'Library Project',
356
-      'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000000514203-fsvbcj-large.jpg?04ad178',
356
+      'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000000514203-fsvbcj-large.jpg?51826bf',
357 357
       'data_type' => 'playlist',
358 358
       'data_download' => null,
359 359
       'data_download_url' => 'http://soundcloud.com/matas/sets/library-project/download',
@@ -368,7 +368,7 @@ class ElementFactoryTest extends UnitTest
368 368
     $this->assertEquals(array(
369 369
       'data_ref_id' => 3154252,
370 370
       'data_title' => 'Above Hyperion (redux)',
371
-      'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000001536693-gb1n5v-large.jpg?04ad178',
371
+      'data_thumb_url' => 'http://i1.sndcdn.com/artworks-000001536693-gb1n5v-large.jpg?51826bf',
372 372
       'data_type' => 'track',
373 373
       'data_download' => false,
374 374
       'data_download_url' => 'http://soundcloud.com/matas/above-hyperion-redux/download',