Преглед изворни кода

Gestion des tracks deezer + cover + album name + title name.

Sevajol Bastien пре 12 година
родитељ
комит
b54d4cd93a
1 измењених фајлова са 41 додато и 1 уклоњено
  1. 41 1
      src/Muzich/CoreBundle/Factory/Elements/Deezercom.php

+ 41 - 1
src/Muzich/CoreBundle/Factory/Elements/Deezercom.php Прегледај датотеку

@@ -41,12 +41,25 @@ class Deezercom extends ElementFactory
41 41
       $type   = 'album';
42 42
       $ref_id = $chaines[1];
43 43
     }
44
+    // http://www.deezer.com/fr/album/379324
45
+    else if (preg_match("#^\/[a-zA-Z_-]+\/album\/([0-9]+)#", $url_clean, $chaines))
46
+    {
47
+      $type   = 'album';
48
+      $ref_id = $chaines[1];
49
+    }
44 50
     // playlist
45 51
     else if (preg_match("#^\/[a-zA-Z_-]+\/music\/playlist\/([0-9]+)#", $url_clean, $chaines))
46 52
     {
47 53
       $type = 'playlist';
48 54
       $ref_id = $chaines[1];
49 55
     }
56
+    // http://www.deezer.com/track/4067216
57
+    else if (preg_match("#^\/track\/([0-9]+)#", $url_clean, $chaines))
58
+    {
59
+      $type = 'track';
60
+      $ref_id = $chaines[1];
61
+    }
62
+    
50 63
     
51 64
     $this->element->setData(Element::DATA_TYPE  , $type);
52 65
     $this->element->setData(Element::DATA_REF_ID, $ref_id);
@@ -66,7 +79,31 @@ class Deezercom extends ElementFactory
66 79
       {
67 80
         $this->element->setData(Element::DATA_THUMB_URL, $result->cover);
68 81
       }
82
+      else if ($type == 'track')
83
+      {
84
+        if (isset($result->album))
85
+        {
86
+          if (isset($result->album->cover))
87
+          {
88
+            $this->element->setData(Element::DATA_THUMB_URL, $result->album->cover);
89
+          }
90
+        }
91
+      }
69 92
       
93
+      if ($type == 'album' || $type == 'track')
94
+      {
95
+        if (isset($result->title))
96
+        {
97
+          $this->element->setData(Element::DATA_TITLE, $result->title);
98
+        }
99
+        if (isset($result->artist))
100
+        {
101
+          if (isset($result->artist->name))
102
+          {
103
+            $this->element->setData(Element::DATA_ARTIST, $result->artist->name);
104
+          }
105
+        }
106
+      }
70 107
       
71 108
     }
72 109
   }
@@ -74,7 +111,10 @@ class Deezercom extends ElementFactory
74 111
   public function proceedEmbedCode()
75 112
   {
76 113
     if (($ref_id = $this->element->getData(Element::DATA_REF_ID)) 
77
-      && ($type = $this->element->getData(Element::DATA_TYPE)))
114
+      && ($type = $this->element->getData(Element::DATA_TYPE))
115
+      && ($this->element->getData(Element::DATA_TYPE) == 'album' ||
116
+         $this->element->getData(Element::DATA_TYPE) == 'playlist')
117
+      )
78 118
     {
79 119
       $width = $this->container->getParameter('deezer_player_width');
80 120
       $heigth = $this->container->getParameter('deezer_player_height');