Beispiel #1
0
 /**
  * getArtistInfo
  * Returns artist info with biography, image URLs and similar artists, using data from last.fm.
  * Takes artist id in parameter with optional similar artist count and if not present similar artist should be returned.
  */
 public static function getartistinfo($input)
 {
     $id = self::check_parameter($input, 'id');
     $count = $input['count'] ?: 20;
     $includeNotPresent = $input['includeNotPresent'] === "true";
     if (Subsonic_XML_Data::isArtist($id)) {
         $artist_id = Subsonic_XML_Data::getAmpacheId($id);
         $info = Recommendation::get_artist_info($artist_id);
         $similars = Recommendation::get_artists_like($artist_id, $count, !$includeNotPresent);
         $r = Subsonic_XML_Data::createSuccessResponse();
         Subsonic_XML_Data::addArtistInfo($r, $info, $similars);
     } else {
         $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
     }
     self::apiOutput($input, $r);
 }
Beispiel #2
0
 /**
  * insert_local_song
  *
  * Insert a song that isn't already in the database.
  */
 private function insert_local_song($file, $options = array())
 {
     $vainfo = new vainfo($file, $this->get_gather_types('music'), '', '', '', $this->sort_pattern, $this->rename_pattern);
     $vainfo->get_info();
     $key = vainfo::get_tag_type($vainfo->tags);
     $results = vainfo::clean_tag_info($vainfo->tags, $key, $file);
     $results['catalog'] = $this->id;
     if (isset($options['user_upload'])) {
         $results['user_upload'] = $options['user_upload'];
     }
     if (isset($options['license'])) {
         $results['license'] = $options['license'];
     }
     if (isset($options['artist_id'])) {
         $results['artist_id'] = $options['artist_id'];
         $results['albumartist_id'] = $options['artist_id'];
     }
     if (isset($options['album_id'])) {
         $results['album_id'] = $options['album_id'];
     }
     $id = Song::insert($results);
     // If song rating tag exists and is well formed (array user=>rating), add it
     if ($id && array_key_exists('rating', $results) && is_array($results['rating'])) {
         // For each user's ratings, call the function
         foreach ($results['rating'] as $user => $rating) {
             debug_event('Rating', "Setting rating for Song {$id} to {$rating} for user {$user}", 5);
             $o_rating = new Rating($id, 'song');
             $o_rating->set_rating($rating, $user);
         }
     }
     // Extended metadata loading is not deferred, retrieve it now
     if ($id && !AmpConfig::get('deferred_ext_metadata')) {
         $song = new Song($id);
         Recommendation::get_artist_info($song->artist);
     }
     if (Song::isCustomMetadataEnabled()) {
         if (!$song) {
             $song = new Song($id);
         }
         $results = array_diff_key($results, array_flip($song->getDisabledMetadataFields()));
         self::add_metadata($song, $results);
     }
     $this->added_songs_to_gather[] = $id;
     $this->_filecache[strtolower($file)] = $id;
     return $id;
 }
Beispiel #3
0
     if (count($videos) and is_array($videos)) {
         ob_start();
         require_once AmpConfig::get('prefix') . UI::find_template('show_random_videos.inc.php');
         $results['random_video_selection'] = ob_get_clean();
     } else {
         $results['random_video_selection'] = '<!-- None found -->';
     }
     break;
 case 'artist_info':
     if (AmpConfig::get('lastfm_api_key') && (isset($_REQUEST['artist']) || isset($_REQUEST['fullname']))) {
         if ($_REQUEST['artist']) {
             $artist = new Artist($_REQUEST['artist']);
             $artist->format();
             $biography = Recommendation::get_artist_info($artist->id);
         } else {
             $biography = Recommendation::get_artist_info(null, rawurldecode($_REQUEST['fullname']));
         }
         ob_start();
         require_once AmpConfig::get('prefix') . UI::find_template('show_artist_info.inc.php');
         $results['artist_biography'] = ob_get_clean();
     }
     break;
 case 'similar_artist':
     if (AmpConfig::get('show_similar') && isset($_REQUEST['artist'])) {
         $artist = new Artist($_REQUEST['artist']);
         $artist->format();
         $object_ids = array();
         $missing_objects = array();
         if ($similars = Recommendation::get_artists_like($artist->id, 10, !AmpConfig::get('wanted'))) {
             foreach ($similars as $similar) {
                 if ($similar['id']) {
Beispiel #4
0
 /**
  * insert_local_song
  *
  * Insert a song that isn't already in the database.
  */
 private function insert_local_song($file, $options = array())
 {
     $vainfo = new vainfo($file, $this->get_gather_types('music'), '', '', '', $this->sort_pattern, $this->rename_pattern);
     $vainfo->get_info();
     $key = vainfo::get_tag_type($vainfo->tags);
     $results = vainfo::clean_tag_info($vainfo->tags, $key, $file);
     $results['catalog'] = $this->id;
     if (isset($options['user_upload'])) {
         $results['user_upload'] = $options['user_upload'];
     }
     if (isset($options['license'])) {
         $results['license'] = $options['license'];
     }
     if (isset($options['artist_id'])) {
         $results['artist_id'] = $options['artist_id'];
         $results['albumartist_id'] = $options['artist_id'];
     }
     if (isset($options['album_id'])) {
         $results['album_id'] = $options['album_id'];
     }
     $id = Song::insert($results);
     // Extended metadata loading is not deferred, retrieve it now
     if ($id && !AmpConfig::get('deferred_ext_metadata')) {
         $song = new Song($id);
         Recommendation::get_artist_info($song->artist);
     }
     $this->added_songs_to_gather[] = $id;
     $this->_filecache[strtolower($file)] = $id;
     return $id;
 }