|
@@ -38,58 +38,65 @@ class Jamendocom extends ElementFactory
|
38
|
38
|
}
|
39
|
39
|
}
|
40
|
40
|
|
41
|
|
- public function retrieveDatas()
|
|
41
|
+
|
|
42
|
+ public function proceedDatas()
|
42
|
43
|
{
|
43
|
|
- $type = $this->element->getData(Element::DATA_TYPE);
|
44
|
|
- $ref_id = $this->element->getData(Element::DATA_REF_ID);
|
45
|
|
-
|
46
|
|
- // Récupération de données avec l'API
|
47
|
|
- $api_url = null;
|
48
|
|
- switch ($type)
|
|
44
|
+ $this->retrieveDatas();
|
|
45
|
+ // TODO: A t-on toujours besoin du code embed ou on génrère le player générique a la volée ?
|
|
46
|
+ $this->proceedEmbedCode();
|
|
47
|
+ $this->proceedThumbnailUrl();
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ protected function getApiUrl()
|
|
51
|
+ {
|
|
52
|
+ switch ($this->url_analyzer->getType())
|
49
|
53
|
{
|
50
|
54
|
case Element::TYPE_ALBUM:
|
51
|
|
- $api_url = "http://api.jamendo.com/get2/"
|
52
|
|
- ."id+name+url+image+artist_name+artist_url/album/json/?album_id=".$ref_id;
|
53
|
|
- $api_tag_url = "http://api.jamendo.com/get2/name+weight/tag/json/album_tag/?album_id=".$ref_id;
|
|
55
|
+ return "http://api.jamendo.com/get2/id+name+url+image+artist_name+artist_url/album/json/?album_id="
|
|
56
|
+ .$this->url_analyzer->getRefId();
|
54
|
57
|
break;
|
55
|
|
-
|
56
|
58
|
case Element::TYPE_TRACK:
|
57
|
|
- $api_url = "http://api.jamendo.com/get2/"
|
58
|
|
- ."id+name+url+image+artist_name+artist_url+track_name/album/json/?track_id=".$ref_id;
|
59
|
|
- $api_tag_url = "http://api.jamendo.com/get2/name+weight/tag/json/track_tag/?track_id=".$ref_id;
|
|
59
|
+ return "http://api.jamendo.com/get2/id+name+url+image+artist_name+artist_url+track_name/album/json/?track_id="
|
|
60
|
+ .$this->url_analyzer->getRefId();
|
60
|
61
|
break;
|
61
|
62
|
}
|
62
|
|
-
|
63
|
|
- if ($api_url)
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ protected function getApiTagUrl()
|
|
66
|
+ {
|
|
67
|
+ return "http://api.jamendo.com/get2/name+weight/tag/json/album_tag/?".$this->url_analyzer->getType()."_id="
|
|
68
|
+ .$this->url_analyzer->getRefId();
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ public function retrieveDatas()
|
|
72
|
+ {
|
|
73
|
+ if (($response = $this->getApiConnector()->getResponseForUrl($this->getApiUrl())))
|
64
|
74
|
{
|
65
|
|
- if (($response = $this->getApiConnector()->getResponseForUrl($api_url)))
|
|
75
|
+ // Check si tout se passe bien si pas de retour de l'api
|
|
76
|
+ $this->getApiConnector()->setElementDatasWithResponse($response, array(
|
|
77
|
+ Element::DATA_THUMB_URL => array(0 => 'image'),
|
|
78
|
+ Element::DATA_ARTIST => array(0 => 'artist_name'),
|
|
79
|
+ ));
|
|
80
|
+
|
|
81
|
+ if ($this->url_analyzer->getType() == Element::TYPE_ALBUM)
|
66
|
82
|
{
|
67
|
|
- // Check si tout se passe bien si pas de retour de l'api
|
68
|
|
- $this->getApiConnector()->setElementDatasWithResponse($response, array(
|
69
|
|
- Element::DATA_THUMB_URL => array(0 => 'image'),
|
70
|
|
- Element::DATA_ARTIST => array(0 => 'artist_name'),
|
71
|
|
- ));
|
72
|
|
-
|
73
|
|
- if ($this->url_analyzer->getType() == Element::TYPE_ALBUM)
|
74
|
|
- {
|
75
|
|
- $this->element->setData(Element::DATA_TITLE, $response->get(array(0 => 'name')));
|
76
|
|
- }
|
77
|
|
- if ($this->url_analyzer->getType() == Element::TYPE_TRACK)
|
|
83
|
+ $this->element->setData(Element::DATA_TITLE, $response->get(array(0 => 'name')));
|
|
84
|
+ }
|
|
85
|
+ if ($this->url_analyzer->getType() == Element::TYPE_TRACK)
|
|
86
|
+ {
|
|
87
|
+ $this->element->setData(Element::DATA_TITLE, $response->get(array(0 => 'track_name')));
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ if (($response = $this->getApiConnector()->getResponseForUrl($this->getApiTagUrl())))
|
|
91
|
+ {
|
|
92
|
+ // TODO: Check si tout ce passe bien avec pas de tags en retour de l'api
|
|
93
|
+ $tags = array();
|
|
94
|
+ foreach ($result->getContent() as $tag)
|
78
|
95
|
{
|
79
|
|
- $this->element->setData(Element::DATA_TITLE, $response->get(array(0 => 'track_name')));
|
|
96
|
+ $tags[] = $tag['name'];
|
80
|
97
|
}
|
81
|
98
|
|
82
|
|
- if (($response = $this->getApiConnector()->getResponseForUrl($api_url)))
|
83
|
|
- {
|
84
|
|
- // TODO: Check si tout ce passe bien avec pas de tags en retour de l'api
|
85
|
|
- $tags = array();
|
86
|
|
- foreach ($result->getContent() as $tag)
|
87
|
|
- {
|
88
|
|
- $tags[] = $tag['name'];
|
89
|
|
- }
|
90
|
|
-
|
91
|
|
- $this->element->setData(Element::DATA_TAGS, $tags);
|
92
|
|
- }
|
|
99
|
+ $this->element->setData(Element::DATA_TAGS, $tags);
|
93
|
100
|
}
|
94
|
101
|
}
|
95
|
102
|
|