Topic: ZR Development (9)


New JSON Feed for Recent Tracks

We just added a JSON formatted feed for recent tracks to make manipulation with JavaScript easier. The JSON feeds work lust like the recent tracks feeds:

Full feed: http://zenradar.roblogic.net/service/1.0/user/[username]/recenttracks.json
Specify number of results (1-10): http://zenradar.roblogic.net/service/1.0/user/[username]/recenttracks_[1-10].json

Here's the easy way to cache the feed on your site. Run this script from cron on a regular basis, then pull the cached file in your JavaScript to keep things snappy.
<?php
//from marc2003's script on last.fm forum
$user 'roblogic'//last.fm username

$remotefile "http://zenradar.roblogic.net/service/1.0/user/$user/
recenttracks.json"
;
$localfile $user.'.json';

try
{    
    
$ch curl_init($remotefile);
    
$fp fopen($localfile"w");
    
    
curl_setopt($chCURLOPT_FILE$fp);
    
curl_setopt($chCURLOPT_HEADER0);
    
    
curl_exec($ch);
    
curl_close($ch);
    
fclose($fp);

}
catch (
Exception $e)
{
    echo 
$e->getMessage();
    echo 
'<pre>';
    echo 
$e->getTraceAsString();
    echo 
'</pre>';
}

Artist images in recent tracks feed

Someone on the last.fm forums was asking about artist images for recently scrobbled tracks, so I though I'd look into adding them to our recent tracks feed.

Unfortunately, that artist info is really hard to get to on-demand. There's no info feed for artists, so even though you can get Similar Artists, Top Fans, Top Tracks, Top Albums, Top Tags, and Current Events, you can't get a simple artist detail. However, if you pull the similar artists feed, pick the first artist in the list, then pull that artist's similar artists feed, you can spin through those artists and find the target artist. This method does work, but does not seem to generate matches for all artists, so there are some blanks here and there. I've got a cron job running to update all of the artists that are already cached in our DB (around 1100) with the image data, it should be done by this time tomorrow. Any artists not already in our DB will have their image data saved as they come in on the last.fm recent tracks feeds.

ZenRadar recent tracks feeds now have small and large artist images in the artist nodes, like this:

<artist mbid="">
    Sound Tribe Sector 9
    <url>http://www.last.fm/music/Sound+Tribe+Sector+9</url>
    <image_small>http://userserve-ak.last.fm/serve/50/86460.jpg</image_small>
    <image_large>http://userserve-ak.last.fm/serve/160/86460.jpg</image_large>
</artist>

Which will give you:




Artists that we haven't found images for will have the last.fm default "no artist" images:


http://cdn.last.fm/depth/catalogue/noimage/noartist_50px.jpg


http://cdn.last.fm/depth/catalogue/noimage/noartist_140px.jpg

I hope this is useful, let me know if you have any questions, or if you'd like artist images added to any of the other feeds.

Zen Radar on build.last.fm

Zen Radar on build.last.fm

"Last.fm feeds on crack. All the enhancements you ever wanted."

ZR has been added to build.last.fm. We're proud to be a part of the growing last.fm developer community.

If you're new here, take a moment to read about what this thing is and find out how to use it. If you have questions, check the FAQ, or feel free to contact us. If you're ready to get a closer look, create an account and dive right in.


Recent Loved Tracks RSS

Some people on the last.fm forum have been asking for an RSS feed for recently loved tracks, so I whipped one up for ZR users. This feed does not contain album info or art, if you find this feed useful, and would like to see the album info added, let us know.

Here's the feed URL:
http://zenradar.roblogic.net/service/1.0/user/[your username]/recentlovedtracks.rss

I'm not sure if there is much demand for RSS over XML, if you'd like to have more RSS feeds, speak up and we'll get on it.

last.fm & audioscrobbler offline

last.fm and ws.audioscrobbler.com went down temporarily this morning. We took this opportunity to enhance some of the error handling in the feeds in order to fail gracefully in this situation. Our recent tracks feeds are unphased by such an outage, your feed will be pulled entirely from our cached data. The other feeds will simply be empty.

As of this post, the servers seem to be back online.

Feed Format Changed

We've changed the format of the feeds slightly in order to more closely mirror the audioscrobbler format. The change affects the cover art in the album block.

The new format is:
<album>
    <name></name>
    <url></url>
    <coverart>
        <small></small>
        <medium></medium>
        <large></large>
    </coverart>       
</album>


Changed from:
<album>
    <name></name>
    <url></url>
    <coverart_small></coverart_small>
    <coverart_medium></coverart_medium>
    <coverart_large></coverart_large>      
</album>


Thanks to johnnaked for keeping us in line

Recent Tracks Widget

This little widget displays your recent tracks list with album data, and lists your last.fm friends. If they have ZenRadar accounts, you can see their lists too. The widget is based on jcr313's excellent last.fm recent tracks widget. Thanks James!

Since your ZR info requires requests to your feeds in order to stay up-to-date, this widget can help keep your recent tracks data in sync.

Mac OS X 10.4 Tiger is required. If you’re using Safari, click the download link. When the widget download is complete, show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it. If you’re using a browser other than Safari, click the download link. When the widget download is complete, unarchive it and place it in /Library/Widgets/ in your home folder. show Dashboard, click the Plus sign to display the Widget Bar and click the widget’s icon in the Widget Bar to open it.

Download Now!



Recent Tracks Quilts

Your recent tracks can be displayed as an album cover quilt. The quilt is displayed as an HTML table. You can choose any square number to display between 4 and 49.

Hakan Lidbo - Proton/Elektron - Mainhatten Sound Northern Exposure III: Expeditions (Disc 1) - Northern Exposure III: Expeditions They Never Got You - Gimme Fiction Sea to Sea - Live at Stubb Colonel Josh Monster Man - El Oso Stand - Greatest Hits
I Want to Take You Higher - Greatest Hits Big and Bad - This Beautiful Life Devil in Jersey City - The Second Stage Turbine Blade Midwest Sky - @ Home So Far I Have Not Found The Science - El Oso Of Course - Ritual de lo Habitual She - Dookie
The Platform - The Platform Good - Good The Only One - Good Young Urban - Ambulance LTD Planet Of The Shapes - Lush 3.1 - Lush 3.2 - Impact (The Earth Is Burning) - Remind - Orbital 2 Mile High - B-Sides and Otherwise RE: DEFinition - Black Star
Early to Bed - Like Swimming Why Do I Lie? - Fever In Fever Out Fight for Your Mind - Fight for Your Mind The Richest Man in Babylon - The Richest Man in Babylon Walk Now... - Orbital 2 LP Retreat - Natural Ingredients Paris - Emotional Technology
Until the Morning (Rewound by Kid Loco) - Babylon Rewound Farewell Ferengistan - Farewell Ferengistan High Plains Drifter (Live) - Live Transmissions I Failed to Use It - Rockity Roll One Chance - Good News for People Who Love Bad News Inhale - Eleventh Besos De Sal - Gran Hotel Buenos Aires
Crown of Love - Funeral 40 Grand in the Hole - Rockity Roll M.E. - Dubnobasswithmyheadman Murder of Soul - Krush In Front Of - Strength ReEmergence, Beat The Science Remix (Karsh Kale) - Artifact Perspectives Samba De Uma Nota So - Jazz Samba
Fighting in Built Up Areas - Witching Hour Keep on Rockin Babylon Times - See The Light Samba Triste - Jazz Samba Flowin Off On One - Moonroof Operator Convenient Parking - The Lonesome Crowded West


http://zenradar.roblogic.net/service/1.0/user/[username]/quilts/recenttracks_4.html

http://zenradar.roblogic.net/service/1.0/user/[username]/quilts/recenttracks_9.html
http://zenradar.roblogic.net/service/1.0/user/[username]/quilts/recenttracks_16.html
http://zenradar.roblogic.net/service/1.0/user/[username]/quilts/recenttracks_25.html
http://zenradar.roblogic.net/service/1.0/user/[username]/quilts/recenttracks_36.html
http://zenradar.roblogic.net/service/1.0/user/[username]/quilts/recenttracks_49.html

New Feeds Available

You can now pull your weekly top albums, weekly top tracks, top albums, and top tracks feeds, complete with album info. Currently, we're limiting the feeds to the top 10. Links can be found on your dashboard.

Examples:
Top Tracks
Top Albums
Weekly Track Chart
Weekly Album Chart