Browse Source

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

Sevajol Bastien 12 years ago
parent
commit
b54d4cd93a
1 changed files with 41 additions and 1 deletions
  1. 41 1
      src/Muzich/CoreBundle/Factory/Elements/Deezercom.php

+ 41 - 1
src/Muzich/CoreBundle/Factory/Elements/Deezercom.php View File

41
       $type   = 'album';
41
       $type   = 'album';
42
       $ref_id = $chaines[1];
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
     // playlist
50
     // playlist
45
     else if (preg_match("#^\/[a-zA-Z_-]+\/music\/playlist\/([0-9]+)#", $url_clean, $chaines))
51
     else if (preg_match("#^\/[a-zA-Z_-]+\/music\/playlist\/([0-9]+)#", $url_clean, $chaines))
46
     {
52
     {
47
       $type = 'playlist';
53
       $type = 'playlist';
48
       $ref_id = $chaines[1];
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
     $this->element->setData(Element::DATA_TYPE  , $type);
64
     $this->element->setData(Element::DATA_TYPE  , $type);
52
     $this->element->setData(Element::DATA_REF_ID, $ref_id);
65
     $this->element->setData(Element::DATA_REF_ID, $ref_id);
66
       {
79
       {
67
         $this->element->setData(Element::DATA_THUMB_URL, $result->cover);
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
   public function proceedEmbedCode()
111
   public function proceedEmbedCode()
75
   {
112
   {
76
     if (($ref_id = $this->element->getData(Element::DATA_REF_ID)) 
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
       $width = $this->container->getParameter('deezer_player_width');
119
       $width = $this->container->getParameter('deezer_player_width');
80
       $heigth = $this->container->getParameter('deezer_player_height');
120
       $heigth = $this->container->getParameter('deezer_player_height');