Skip to content

Instantly share code, notes, and snippets.

@dewey
Created June 22, 2013 16:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dewey/5841485 to your computer and use it in GitHub Desktop.
Save dewey/5841485 to your computer and use it in GitHub Desktop.
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