Created
June 22, 2013 16:30
-
-
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
This file contains hidden or 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/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