public function getArtistInfo($name)
{
if (!$this->enabled()) {
return false;
}
$name = urlencode($name);
try {
$cacheKey = md5("lastfm_artist_{$name}");
if ($response = Cache::get($cacheKey)) {
$response = simplexml_load_string($response);
} else {
if ($response = $this->get("?method=artist.getInfo&autocorrect=1&artist={$name}")) {
Cache::put($cacheKey, $response->asXML(), 24 * 60 * 7);
}
}
$response = json_decode(json_encode($response), true);
if (!$response || !($artist = array_get($response, 'artist'))) {
return false;
}
return ['url' => array_get($artist, 'url'), 'image' => count($artist['image']) > 3 ? $artist['image'][3] : $artist['image'][0], 'bio' => ['summary' => $this->formatText(array_get($artist, 'bio.summary')), 'full' => $this->formatText(array_get($artist, 'bio.content'))]];
} catch (Exception $e) {
Log::error($e);
return false;
}
}