Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Last.fm "now playing" script for Textual. Installation: Replace 'apfeltalkdewey' with your Last.fm username. Copy this script to ~/Library/Application Scripts/com.codeux.irc.textual/lastfm.php Usage: /lastfm
#!/usr/bin/php
<?php
$doc = new DOMDocument();
$doc->load("http://ws.audioscrobbler.com/2.0/user/apfeltalkdewey/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
);
array_push($arrFeeds, $itemRSS);
}
echo ("/me is listening 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
You can’t perform that action at this time.