/** * get_artist_info * Returns artist information */ public static function get_artist_info($artist_id, $fullname = '') { $artist = null; if ($artist_id) { $artist = new Artist($artist_id); $artist->format(); $fullname = $artist->f_full_name; // Data newer than 6 months, use it if ($artist->last_update + 15768000 > time()) { $results = array(); $results['summary'] = $artist->summary; $results['placeformed'] = $artist->placeformed; $results['yearformed'] = $artist->yearformed; $results['largephoto'] = Art::url($artist->id, 'artist'); $results['megaphoto'] = $results['largephoto']; return $results; } } $query = 'artist=' . rawurlencode($fullname); $xml = self::get_lastfm_results('artist.getinfo', $query); $results = array(); $results['summary'] = strip_tags(preg_replace("#<a href=([^<]*)Last\\.fm</a>.#", "", (string) $xml->artist->bio->summary)); $results['placeformed'] = (string) $xml->artist->bio->placeformed; $results['yearformed'] = (string) $xml->artist->bio->yearformed; $results['largephoto'] = $xml->artist->image[2]; $results['megaphoto'] = $xml->artist->image[4]; if ($artist) { if (!empty($results['summary']) || !empty($results['megaphoto'])) { $artist->update_artist_info($results['summary'], $results['placeformed'], $results['yearformed']); $image = Art::get_from_source(array('url' => $results['megaphoto']), 'artist'); $rurl = pathinfo($results['megaphoto']); $mime = 'image/' . $rurl['extension']; $art = new Art($artist->id, 'artist'); $art->reset(); $art->insert($image, $mime); $results['largephoto'] = Art::url($artist->id, 'artist'); $results['megaphoto'] = $results['largephoto']; } } return $results; }