Correctly process Lastfm songs that are currently playing and display that information to the page.

This commit is contained in:
Andrew Tomaka 2011-10-14 05:17:04 -04:00
parent f64e4246f6
commit 5649bc6f4f
2 changed files with 6 additions and 2 deletions

View file

@ -101,11 +101,15 @@ function lastfm() {
$cover = (is_array($latestSong->image)) ? $cover = (is_array($latestSong->image)) ?
'img/lastfm/blank_album64.png' : (string)$latestSong->image[1]; 'img/lastfm/blank_album64.png' : (string)$latestSong->image[1];
$time = (isset($latestSong->attributes()->nowplaying) && (bool)$latestSong->attributes()->nowplaying) ?
0 : strtotime($latestSong->date . ' UTC');
print_r($time);
return array( return array(
'song' => (string)$latestSong->name, 'song' => (string)$latestSong->name,
'artist' => (string)$latestSong->artist, 'artist' => (string)$latestSong->artist,
'time' => strtotime($latestSong->date . ' UTC'), 'time' => $time,
'url' => (string)$latestSong->url, 'url' => (string)$latestSong->url,
'cover' => $cover, 'cover' => $cover,
); );

View file

@ -98,7 +98,7 @@ while($link = $links->fetch_object()) {
<span class="right"><a href="http://last.fm/user/atomaka"><img src="img/badges/lastfm.png" class="icon" alt="Andrew Tomaka's Last.fm" /></a></span> <span class="right"><a href="http://last.fm/user/atomaka"><img src="img/badges/lastfm.png" class="icon" alt="Andrew Tomaka's Last.fm" /></a></span>
<a href="<?php echo $data->lastfm->url ?>"><?php echo $data->lastfm->song ?></a><br/> <a href="<?php echo $data->lastfm->url ?>"><?php echo $data->lastfm->song ?></a><br/>
by <?php echo $data->lastfm->artist ?><br/><br/> by <?php echo $data->lastfm->artist ?><br/><br/>
<?php echo time_since($data->lastfm->time) ?> ago<br/> <?php echo ($data->lastfm->time == 0) ? 'currently playing' : time_since($data->lastfm->time) . 'ago' ?><br/>
</td> </td>
</tr> </tr>
</table> </table>