| 147 | | if(strtok('/')) { |
| 148 | | $albums= $this->api->fetch('artist.getTopAlbums', array('artist' => $artist)); |
| 149 | | |
| 150 | | foreach($albums->topalbums->album as $album) { |
| 151 | | $props = array(); |
| 152 | | $props['title'] = (string)$album->name; |
| 153 | | $props['url'] = (string)$album->url; |
| 154 | | $props['icon'] = (string)$album->image[0]; |
| 155 | | $props['thumbnail_url'] = (string)$album->image[0]; |
| 156 | | $props['image_url'] = (string)$album->image[3]; |
| 157 | | $props['filetype'] = 'album'; |
| | 184 | if($level = strtok('/')) { |
| | 185 | if($level == 'albums') { |
| | 186 | $albums= $this->api->fetch('artist.getTopAlbums', array('artist' => $artist)); |
| | 187 | |
| | 188 | foreach($albums->topalbums->album as $album) { |
| | 189 | $props = array(); |
| | 190 | $props['title'] = (string)$album->name; |
| | 191 | $props['url'] = (string)$album->url; |
| | 192 | $props['icon'] = (string)$album->image[1]; |
| | 193 | $props['thumbnail_url'] = (string)$album->image[1]; |
| | 194 | $props['image_url'] = (string)$album->image[2]; |
| | 195 | $props['filetype'] = 'lastfm'; |
| | 196 | |
| | 197 | $results[] = new MediaAsset( |
| | 198 | self::SILO_NAME . '/tags/' . $selected . '/' . $artist . '/' . (string)$album->mbid, |
| | 199 | false, |
| | 200 | $props |
| | 201 | ); |
| | 202 | } |
| | 203 | } elseif($level == 'songs') { |
| | 204 | $tracks= $this->api->fetch('artist.getTopTracks', array('artist' => $artist)); |
| | 258 | |
| | 259 | case 'artists': |
| | 260 | if($artist = strtok('/')) { |
| | 261 | if($level = strtok('/')) { |
| | 262 | if($level == 'albums') { |
| | 263 | $albums= $this->api->fetch('artist.getTopAlbums', array('artist' => $artist)); |
| | 264 | |
| | 265 | foreach($albums->topalbums->album as $album) { |
| | 266 | $props = array(); |
| | 267 | $props['title'] = (string)$album->name; |
| | 268 | $props['url'] = (string)$album->url; |
| | 269 | $props['icon'] = (string)$album->image[1]; |
| | 270 | $props['thumbnail_url'] = (string)$album->image[1]; |
| | 271 | $props['image_url'] = (string)$album->image[2]; |
| | 272 | $props['filetype'] = 'lastfm'; |
| | 273 | |
| | 274 | $results[] = new MediaAsset( |
| | 275 | self::SILO_NAME . '/artists/' . $artist . '/' . (string)$album->mbid, |
| | 276 | false, |
| | 277 | $props |
| | 278 | ); |
| | 279 | } |
| | 280 | } elseif($level == 'songs') { |
| | 281 | $tracks= $this->api->fetch('artist.getTopTracks', array('artist' => $artist)); |
| | 282 | |
| | 283 | foreach($tracks->toptracks->track as $track) { |
| | 284 | $props = array(); |
| | 285 | $props['title'] = (string)$track->name; |
| | 286 | $props['url'] = (string)$track->url; |
| | 287 | $props['icon'] = (string)$track->image[1]; |
| | 288 | $props['thumbnail_url'] = (string)$track->image[1]; |
| | 289 | $props['image_url'] = (string)$track->image[2]; |
| | 290 | $props['filetype'] = 'lastfm'; |
| | 291 | |
| | 292 | $results[] = new MediaAsset( |
| | 293 | self::SILO_NAME . '/artists/' . $artist . '/' . (string)$track->name, |
| | 294 | false, |
| | 295 | $props |
| | 296 | ); |
| | 297 | } |
| | 298 | } |
| | 299 | } else { |
| | 300 | $results[] = new MediaAsset( |
| | 301 | self::SILO_NAME . '/artists/' . $artist . '/albums', |
| | 302 | true, |
| | 303 | array('title' => 'Albums') |
| | 304 | ); |
| | 305 | $results[] = new MediaAsset( |
| | 306 | self::SILO_NAME . '/artists/' . $artist . '/songs', |
| | 307 | true, |
| | 308 | array('title' => 'Songs') |
| | 309 | ); |
| | 310 | } |
| | 311 | } else { |
| | 312 | $artists= $this->api->fetch('user.getTopArtists', array('user' => User::identify()->info->lastfm__username)); |
| | 313 | |
| | 314 | foreach($artists->topartists->artist as $artist) { |
| | 315 | $results[] = new MediaAsset( |
| | 316 | self::SILO_NAME . '/artists/' . (string)$artist->name, |
| | 317 | true, |
| | 318 | array('title' => (string)$artist->name) |
| | 319 | ); |
| | 320 | } |
| | 321 | } |
| | 322 | break; |
| | 323 | |
| | 324 | case 'albums': |
| | 325 | $albums= $this->api->fetch('library.getAlbums', array('user' => User::identify()->info->lastfm__username)); |
| | 326 | |
| | 327 | foreach($albums->albums->album as $album) { |
| | 328 | $props = array(); |
| | 329 | $props['title'] = (string)$album->name; |
| | 330 | $props['url'] = (string)$album->url; |
| | 331 | $props['icon'] = (string)$album->image[1]; |
| | 332 | $props['thumbnail_url'] = (string)$album->image[1]; |
| | 333 | $props['image_url'] = (string)$album->image[2]; |
| | 334 | $props['filetype'] = 'lastfm'; |
| | 335 | |
| | 336 | $results[] = new MediaAsset( |
| | 337 | self::SILO_NAME . '/albums/'. (string)$album->mbid, |
| | 338 | false, |
| | 339 | $props |
| | 340 | ); |
| | 341 | } |
| | 342 | |
| | 343 | break; |
| | 344 | |
| | 345 | case 'songs': |
| | 346 | $tracks= $this->api->fetch('user.getTopTracks', array('user' => User::identify()->info->lastfm__username)); |
| | 347 | |
| | 348 | foreach($tracks->toptracks->track as $track) { |
| | 349 | $props = array(); |
| | 350 | $props['title'] = (string)$track->name; |
| | 351 | $props['url'] = (string)$track->url; |
| | 352 | $props['icon'] = (string)$track->image[1]; |
| | 353 | $props['thumbnail_url'] = (string)$track->image[1]; |
| | 354 | $props['image_url'] = (string)$track->image[2]; |
| | 355 | $props['filetype'] = 'lastfm'; |
| | 356 | |
| | 357 | $results[] = new MediaAsset( |
| | 358 | self::SILO_NAME . '/songs/'. (string)$track->url, |
| | 359 | false, |
| | 360 | $props |
| | 361 | ); |
| | 362 | } |
| | 363 | |
| | 364 | break; |
| | 365 | |
| | 366 | case 'recent': |
| | 367 | $tracks= $this->api->fetch('user.getRecentTracks', array('user' => User::identify()->info->lastfm__username)); |
| | 368 | |
| | 369 | foreach($tracks->recenttracks->track as $track) { |
| | 370 | $props = array(); |
| | 371 | $props['title'] = (string)$track->name; |
| | 372 | $props['url'] = (string)$track->url; |
| | 373 | $props['icon'] = (string)$track->image[1]; |
| | 374 | $props['thumbnail_url'] = (string)$track->image[1]; |
| | 375 | $props['image_url'] = (string)$track->image[2]; |
| | 376 | $props['filetype'] = 'lastfm'; |
| | 377 | |
| | 378 | $results[] = new MediaAsset( |
| | 379 | self::SILO_NAME . '/recent/'. (string)$track->url, |
| | 380 | false, |
| | 381 | $props |
| | 382 | ); |
| | 383 | } |
| | 384 | |
| | 385 | break; |
| | 386 | |
| | 387 | case 'favorites': |
| | 388 | $tracks= $this->api->fetch('user.getLovedTracks', array('user' => User::identify()->info->lastfm__username)); |
| | 389 | |
| | 390 | foreach($tracks->lovedtracks->track as $track) { |
| | 391 | $props = array(); |
| | 392 | $props['title'] = (string)$track->name; |
| | 393 | $props['url'] = (string)$track->url; |
| | 394 | $props['icon'] = (string)$track->image[1]; |
| | 395 | $props['thumbnail_url'] = (string)$track->image[1]; |
| | 396 | $props['image_url'] = (string)$track->image[2]; |
| | 397 | $props['filetype'] = 'lastfm'; |
| | 398 | |
| | 399 | $results[] = new MediaAsset( |
| | 400 | self::SILO_NAME . '/favorites/'. (string)$track->url, |
| | 401 | false, |
| | 402 | $props |
| | 403 | ); |
| | 404 | } |
| | 405 | |
| | 406 | break; |
| | 407 | |