Skip to content

Commit

Permalink
Added duration information for tracks whilst the API doesn't give it …
Browse files Browse the repository at this point in the history
…for getSimilar
  • Loading branch information
NeilCrosby committed Dec 16, 2008
1 parent eb772cc commit 2af07ec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions classes/LastGenius.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ function getPlaylist($track, $artist, $numTracksRequired = 10) {
if ( $item->match < 0.85 * $bestMatch ) {
break;
}

// make an extra request if we don't know how long the track is
if (!$item->duration) {
$url = LAST_FM_API_URL.'?method=track.getinfo&artist='.urlencode($item->artist->name).'&track='.urlencode($item->name).'&api_key='.LAST_FM_API_KEY;
$data = $curl->getFromXmlSource($url);

$item->addChild('duration', (string)$data->track->duration);
}

array_push($chooseFrom, $item);
}
Expand Down

0 comments on commit 2af07ec

Please sign in to comment.