/** * getInternetRadioStations * Get all internet radio stations * Takes no parameter. */ public static function getinternetradiostations($input) { self::check_version($input, "1.9.0"); $r = Subsonic_XML_Data::createSuccessResponse(); $radios = Live_Stream::get_all_radios(); Subsonic_XML_Data::addRadios($r, $radios); self::apiOutput($input, $r); }
public static function _musicChilds($prmPath, $prmQuery, $start, $count) { $mediaItems = array(); $maxCount = 0; $queryData = array(); parse_str($prmQuery, $queryData); $parent = 'amp://music' . $prmPath; $pathreq = explode('/', $prmPath); if ($pathreq[0] == '' && count($pathreq) > 0) { array_shift($pathreq); } switch ($pathreq[0]) { case 'artists': switch (count($pathreq)) { case 1: // Get artists list //$artists = Catalog::get_artists(); //list($maxCount, $artists) = self::_slice($artists, $start, $count); $artists = Catalog::get_artists(null, $count, $start); list($maxCount, $artists) = array(999999, $artists); foreach ($artists as $artist) { $artist->format(); $mediaItems[] = self::_itemArtist($artist, $parent); } break; case 2: // Get artist's albums list $artist = new Artist($pathreq[1]); if ($artist->id) { $album_ids = $artist->get_albums(); list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count); foreach ($album_ids as $album_id) { $album = new Album($album_id); $album->format(); $mediaItems[] = self::_itemAlbum($album, $parent); } } break; } break; case 'albums': switch (count($pathreq)) { case 1: // Get albums list //!!$album_ids = Catalog::get_albums(); //!!list($maxCount, $album_ids) = self::_slice($album_ids, $start, $count); $album_ids = Catalog::get_albums($count, $start); list($maxCount, $album_ids) = array(999999, $album_ids); foreach ($album_ids as $album_id) { $album = new Album($album_id); $album->format(); $mediaItems[] = self::_itemAlbum($album, $parent); } break; case 2: // Get album's songs list $album = new Album($pathreq[1]); if ($album->id) { $song_ids = $album->get_songs(); list($maxCount, $song_ids) = self::_slice($song_ids, $start, $count); foreach ($song_ids as $song_id) { $song = new Song($song_id); $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } break; } break; case 'songs': switch (count($pathreq)) { case 1: // Get songs list $catalogs = Catalog::get_catalogs(); foreach ($catalogs as $catalog_id) { $catalog = Catalog::create_from_id($catalog_id); $songs = $catalog->get_songs(); list($maxCount, $songs) = self::_slice($songs, $start, $count); foreach ($songs as $song) { $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } break; } break; case 'playlists': switch (count($pathreq)) { case 1: // Get playlists list $pl_ids = Playlist::get_playlists(); list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count); foreach ($pl_ids as $pl_id) { $playlist = new Playlist($pl_id); $playlist->format(); $mediaItems[] = self::_itemPlaylist($playlist, $parent); } break; case 2: // Get playlist's songs list $playlist = new Playlist($pathreq[1]); if ($playlist->id) { $items = $playlist->get_items(); list($maxCount, $items) = self::_slice($items, $start, $count); foreach ($items as $item) { if ($item['object_type'] == 'song') { $song = new Song($item['object_id']); $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } } break; } break; case 'smartplaylists': switch (count($pathreq)) { case 1: // Get playlists list $pl_ids = Search::get_searches(); list($maxCount, $pl_ids) = self::_slice($pl_ids, $start, $count); foreach ($pl_ids as $pl_id) { $playlist = new Search($pl_id, 'song'); $playlist->format(); $mediaItems[] = self::_itemPlaylist($playlist, $parent); } break; case 2: // Get playlist's songs list $playlist = new Search($pathreq[1], 'song'); if ($playlist->id) { $items = $playlist->get_items(); list($maxCount, $items) = self::_slice($items, $start, $count); foreach ($items as $item) { if ($item['object_type'] == 'song') { $song = new Song($item['object_id']); $song->format(); $mediaItems[] = self::_itemSong($song, $parent); } } } break; } break; case 'live_streams': switch (count($pathreq)) { case 1: // Get radios list $radios = Live_Stream::get_all_radios(); list($maxCount, $radios) = self::_slice($radios, $start, $count); foreach ($radios as $radio_id) { $radio = new Live_Stream($radio_id); $radio->format(); $mediaItems[] = self::_itemLiveStream($radio, $parent); } break; } break; case 'podcasts': switch (count($pathreq)) { case 1: // Get podcasts list $podcasts = Catalog::get_podcasts(); list($maxCount, $podcasts) = self::_slice($podcasts, $start, $count); foreach ($podcasts as $podcast) { $podcast->format(); $mediaItems[] = self::_itemPodcast($podcast, $parent); } break; case 2: // Get podcast episodes list $podcast = new Podcast($pathreq[1]); if ($podcast->id) { $episodes = $podcast->get_episodes(); list($maxCount, $episodes) = self::_slice($episodes, $start, $count); foreach ($episodes as $episode_id) { $episode = new Podcast_Episode($episode_id); $episode->format(); $mediaItems[] = self::_itemPodcastEpisode($episode, $parent); } } break; } break; default: $mediaItems[] = self::_musicMetadata('artists'); $mediaItems[] = self::_musicMetadata('albums'); $mediaItems[] = self::_musicMetadata('songs'); $mediaItems[] = self::_musicMetadata('playlists'); $mediaItems[] = self::_musicMetadata('smartplaylists'); if (AmpConfig::get('live_stream')) { $mediaItems[] = self::_musicMetadata('live_streams'); } if (AmpConfig::get('podcast')) { $mediaItems[] = self::_musicMetadata('podcasts'); } break; } if ($maxCount == 0) { $maxCount = count($mediaItems); } return array($maxCount, $mediaItems); }