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
     $ref_id = null;
23
     $ref_id = null;
24
     
24
     
25
     // Récupération de l'id
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
       $ref_id = $preg_result[2];
28
       $ref_id = $preg_result[2];
29
       $this->element->setData(Element::DATA_REF_ID, $ref_id);
29
       $this->element->setData(Element::DATA_REF_ID, $ref_id);
42
       
42
       
43
       curl_setopt_array($api_url, $options);
43
       curl_setopt_array($api_url, $options);
44
       $api_result = json_decode(curl_exec($api_url));
44
       $api_result = json_decode(curl_exec($api_url));
45
-      
45
+            
46
       // On récupère l'url du thumbnail
46
       // On récupère l'url du thumbnail
47
       if (isset($api_result->thumbnail_medium_url))
47
       if (isset($api_result->thumbnail_medium_url))
48
       {
48
       {

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

61
       {
61
       {
62
         if (count($result->errors))
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
       $getjsonurl = $result->location;
78
       $getjsonurl = $result->location;
69
       // On a maintenant la bonne url pour demander les infos
79
       // On a maintenant la bonne url pour demander les infos
70
       $ch = curl_init($getjsonurl);
80
       $ch = curl_init($getjsonurl);

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

16
   protected function proceedAPIDatas($ref_id)
16
   protected function proceedAPIDatas($ref_id)
17
   {
17
   {
18
     $video_data_dom = new \DOMDocument;
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
     $this->assertEquals(array(
353
     $this->assertEquals(array(
354
       'data_ref_id' => 3770,
354
       'data_ref_id' => 3770,
355
       'data_title' => 'Library Project',
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
       'data_type' => 'playlist',
357
       'data_type' => 'playlist',
358
       'data_download' => null,
358
       'data_download' => null,
359
       'data_download_url' => 'http://soundcloud.com/matas/sets/library-project/download',
359
       'data_download_url' => 'http://soundcloud.com/matas/sets/library-project/download',
368
     $this->assertEquals(array(
368
     $this->assertEquals(array(
369
       'data_ref_id' => 3154252,
369
       'data_ref_id' => 3154252,
370
       'data_title' => 'Above Hyperion (redux)',
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
       'data_type' => 'track',
372
       'data_type' => 'track',
373
       'data_download' => false,
373
       'data_download' => false,
374
       'data_download_url' => 'http://soundcloud.com/matas/above-hyperion-redux/download',
374
       'data_download_url' => 'http://soundcloud.com/matas/above-hyperion-redux/download',