-
-
Save dgw/de9a364ac50dd109bcae to your computer and use it in GitHub Desktop.
Forked from dewey and changed to display "last listened to" if the latest track in the feed is not currently playing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$doc = new DOMDocument(); | |
$doc->load("http://ws.audioscrobbler.com/2.0/user/voyagerfan5761/recenttracks.xml?limit=1"); | |
$arrFeeds = array(); | |
foreach ($doc->getElementsByTagName('track') as $node) { | |
$itemRSS = array ( | |
'artist' => $node->getElementsByTagName('artist')->item(0)->nodeValue, | |
'name' => $node->getElementsByTagName('name')->item(0)->nodeValue, | |
'nowplaying' => ($node->attributes->getNamedItem('nowplaying')) ? true : false | |
); | |
array_push($arrFeeds, $itemRSS); | |
} | |
$nowplaying = ($arrFeeds[0]['nowplaying']) ? 'is listening' : 'last listened'; | |
echo "/me $nowplaying to {$arrFeeds[0]['name']} by {$arrFeeds[0]['artist']}."; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment