|
@@ -47,159 +47,6 @@ class Soundcloudcom extends ElementFactory
|
47
|
47
|
$this->setElementDatasWithApi();
|
48
|
48
|
}
|
49
|
49
|
|
50
|
|
- ////$this->element->setData(Element::DATA_REF_ID, $this->element->getUrl());
|
51
|
|
- //
|
52
|
|
- //// récupération de données avec l'API
|
53
|
|
- //if ($match)
|
54
|
|
- //{
|
55
|
|
- //
|
56
|
|
- //
|
57
|
|
- //
|
58
|
|
- //
|
59
|
|
- //
|
60
|
|
- // // La première étape consiste a résoudre l'url
|
61
|
|
- // $ch = curl_init('http://api.soundcloud.com/resolve.json?url='.$this->element->getUrl().'&client_id=39946ea18e3d78d64c0ac95a025794e1');
|
62
|
|
- //
|
63
|
|
- // $options = array(
|
64
|
|
- // CURLOPT_RETURNTRANSFER => true,
|
65
|
|
- // CURLOPT_HTTPHEADER => array('Content-type: application/json')
|
66
|
|
- // );
|
67
|
|
- //
|
68
|
|
- // curl_setopt_array( $ch, $options );
|
69
|
|
- // $result = json_decode(curl_exec($ch));
|
70
|
|
- //
|
71
|
|
- // if (isset($result->errors))
|
72
|
|
- // {
|
73
|
|
- // if (count($result->errors))
|
74
|
|
- // {
|
75
|
|
- // return;
|
76
|
|
- // }
|
77
|
|
- // }
|
78
|
|
- //
|
79
|
|
- // if (!isset($result->location))
|
80
|
|
- // {
|
81
|
|
- // return;
|
82
|
|
- // }
|
83
|
|
- //
|
84
|
|
- // if (!$result->location)
|
85
|
|
- // {
|
86
|
|
- // return;
|
87
|
|
- // }
|
88
|
|
- //
|
89
|
|
- // $getjsonurl = $result->location;
|
90
|
|
- // // On a maintenant la bonne url pour demander les infos
|
91
|
|
- // $ch = curl_init($getjsonurl);
|
92
|
|
- // curl_setopt_array($ch, $options);
|
93
|
|
- // $result = json_decode(curl_exec($ch), true);
|
94
|
|
- //
|
95
|
|
- // // En premier lieux il nous faut être sur d'avoir le droit d'utiliser le lecteur exportable
|
96
|
|
- // $sharing = false;
|
97
|
|
- // if (array_key_exists('sharing', $result) && array_key_exists('embeddable_by', $result))
|
98
|
|
- // {
|
99
|
|
- // if ($result['sharing'] == 'public' && ($result['embeddable_by'] == 'all' || $result['embeddable_by'] == 'me'))
|
100
|
|
- // {
|
101
|
|
- // $sharing = true;
|
102
|
|
- // }
|
103
|
|
- // }
|
104
|
|
- //
|
105
|
|
- // if ($sharing)
|
106
|
|
- // {
|
107
|
|
- // if (array_key_exists('id', $result) )
|
108
|
|
- // {
|
109
|
|
- // $this->element->setData(Element::DATA_REF_ID, $result['id']);
|
110
|
|
- // }
|
111
|
|
- //
|
112
|
|
- // if (array_key_exists('uri', $result) )
|
113
|
|
- // {
|
114
|
|
- // $this->element->setData(Element::DATA_NORMALIZED_URL, $result['uri']);
|
115
|
|
- // }
|
116
|
|
- //
|
117
|
|
- // if (array_key_exists('artwork_url', $result) )
|
118
|
|
- // {
|
119
|
|
- // if ($result['artwork_url'])
|
120
|
|
- // {
|
121
|
|
- // $this->element->setData(Element::DATA_THUMB_URL, $result['artwork_url']);
|
122
|
|
- // }
|
123
|
|
- // else
|
124
|
|
- // {
|
125
|
|
- // if (array_key_exists('user', $result) )
|
126
|
|
- // {
|
127
|
|
- // if (array_key_exists('avatar_url', $result['user']) )
|
128
|
|
- // {
|
129
|
|
- // if ($result['user']['avatar_url'])
|
130
|
|
- // {
|
131
|
|
- // $this->element->setData(Element::DATA_THUMB_URL, $result['user']['avatar_url']);
|
132
|
|
- // }
|
133
|
|
- // }
|
134
|
|
- // }
|
135
|
|
- // }
|
136
|
|
- // }
|
137
|
|
- //
|
138
|
|
- // if (array_key_exists('kind', $result) )
|
139
|
|
- // {
|
140
|
|
- // $this->element->setData(Element::DATA_TYPE, $result['kind']);
|
141
|
|
- // }
|
142
|
|
- //
|
143
|
|
- // if (array_key_exists('downloadable', $result) )
|
144
|
|
- // {
|
145
|
|
- // $this->element->setData(Element::DATA_DOWNLOAD, $result['downloadable']);
|
146
|
|
- // // FIXME
|
147
|
|
- // $this->element->setData(Element::DATA_DOWNLOAD_URL, $this->element->getUrl().'/download');
|
148
|
|
- // }
|
149
|
|
- //
|
150
|
|
- // if (array_key_exists('title', $result) )
|
151
|
|
- // {
|
152
|
|
- // $this->element->setData(Element::DATA_TITLE, $result['title']);
|
153
|
|
- // }
|
154
|
|
- //
|
155
|
|
- // if (array_key_exists('user', $result) )
|
156
|
|
- // {
|
157
|
|
- // $this->element->setData(Element::DATA_ARTIST, $result['user']['username']);
|
158
|
|
- // }
|
159
|
|
- //
|
160
|
|
- // $genres = '';
|
161
|
|
- // if (array_key_exists('genre', $result) )
|
162
|
|
- // {
|
163
|
|
- // if (strlen($result['genre']))
|
164
|
|
- // {
|
165
|
|
- // $genres = $result['genre'];
|
166
|
|
- // }
|
167
|
|
- // }
|
168
|
|
- //
|
169
|
|
- // $tags_list = '';
|
170
|
|
- // if (array_key_exists('tag_list', $result) )
|
171
|
|
- // {
|
172
|
|
- // if (strlen($result['tag_list']))
|
173
|
|
- // {
|
174
|
|
- // $tags_list = $result['tag_list'];
|
175
|
|
- // }
|
176
|
|
- // }
|
177
|
|
- //
|
178
|
|
- // $tags_string = $genres.' '.$tags_list.' '.str_replace(' ', '-', $genres);
|
179
|
|
- // $tags_like = array();
|
180
|
|
- // if (strlen($tags_string))
|
181
|
|
- // {
|
182
|
|
- // $tag_like = new TagLike($this->entity_manager);
|
183
|
|
- // foreach (explode(' ', $tags_string) as $word)
|
184
|
|
- // {
|
185
|
|
- // $similar_tags = $tag_like->getSimilarTags($word, ($this->element->getOwner())?$this->element->getOwner()->getId():null);
|
186
|
|
- // if (count($similar_tags))
|
187
|
|
- // {
|
188
|
|
- // if ($similar_tags['same_found'])
|
189
|
|
- // {
|
190
|
|
- // $tags_like[] = $similar_tags['tags'][0]['name'];
|
191
|
|
- // }
|
192
|
|
- // }
|
193
|
|
- // }
|
194
|
|
- // $tags_like[] = $genres;
|
195
|
|
- // if (count($tags_like))
|
196
|
|
- // {
|
197
|
|
- // $this->element->setData(Element::DATA_TAGS, array_unique($tags_like));
|
198
|
|
- // }
|
199
|
|
- // }
|
200
|
|
- //
|
201
|
|
- // }
|
202
|
|
- //}
|
203
|
50
|
}
|
204
|
51
|
|
205
|
52
|
protected function setElementDatasWithApi()
|