1
0
Fork 0

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)) ?
'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(
'song' => (string)$latestSong->name,
'artist' => (string)$latestSong->artist,
'time' => strtotime($latestSong->date . ' UTC'),
'time' => $time,
'url' => (string)$latestSong->url,
'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>
<a href="<?php echo $data->lastfm->url ?>"><?php echo $data->lastfm->song ?></a><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>
</tr>
</table>