コード例 #1
0
ファイル: subsonic_api.class.php プロジェクト: bl00m/ampache
 /**
  * getSimilarSongs
  * Returns a random collection of songs from the given artist and similar artists, using data from last.fm. Typically used for artist radio features.
  * Takes song/album/artist id in parameter with optional similar songs count.
  */
 public static function getsimilarsongs($input)
 {
     $id = self::check_parameter($input, 'id');
     $count = $input['count'] ?: 50;
     $songs = null;
     if (Subsonic_XML_Data::isArtist($id)) {
         // TODO: support similar songs for artists
     } elseif (Subsonic_XML_Data::isAlbum($id)) {
         // TODO: support similar songs for albums
     } elseif (Subsonic_XML_Data::isSong($id)) {
         if (AmpConfig::get('show_similar')) {
             $songs = Recommendation::get_songs_like(Subsonic_XML_Data::getAmpacheId($id));
         }
     }
     if ($songs === null) {
         $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
     } else {
         $r = Subsonic_XML_Data::createSuccessResponse();
         Subsonic_XML_Data::addSimilarSongs($r, $songs);
     }
     self::apiOutput($input, $r);
 }