Tags: last.fm

9

sparkline

Small pieces, loosely joined by machine tags

I’ve already described how machine tags on Huffduffer trigger a number of third-party API calls. Tagging something with music:artist=..., book:author=..., film:title=... or any number of similar machine tags will fire off calls to places like Amazon, The New York Times, or Last.fm.

For a while now, I’ve wanted to include Flickr in that list of third-party services but I couldn’t think of an easy way of associating audio files with photos. Then I realised that a mechanism already exists, and it’s another machine tag. Anything on Flickr that’s been tagged with lastfm:event=... will probably be a picture of a musical artist.

So if anything is tagged on Huffduffer with music:artist=..., all I need to do is fire off a call to Last.fm to get a list of that artist’s events using the method artist.getEvents. Once I have the event IDs I can search Flickr for photos that have been machine tagged with those IDs.

There’s just one problem. Last.fm’s API only returns future events for an artist. There’s no method for past events.

Undeterred, I found a RESTful interface that provides the past events of an artist on Last.fm. The format returned isn’t JSON or XML. It’s HTML. It turns out that past events are freely available in the profile for any artist on Last.fm with the identifier last.fm/music/{artist}/+events/{year}. Here, for example, are Salter Cane gigs in 2009: last.fm/music/Salter+Cane/+events/2009.

If only those events were structured in hCalendar! As it is, I have to run through all the links in the document to find the hrefs beginning with the string http://www.last.fm/event/ and then extract the event ID that immediately follows that string.

Once I’ve extracted the event IDs for an artist, I can fire off a search on Flickr using the flickr.photos.search method with a machine_tags parameter (as well as passing the artist name in the text parameter just to be sure).

Here’s an example result in the sidebar on Huffduffer: huffduffer.com/tags/music:artist=Bat+for+Lashes

It’s messy but it works. I guess that’s the dictionary definition of a hack.

Thoughtful

A few weeks back, I saw that Fanfarlo were going to be playing at The Hanbury Ballroom in Brighton this Wednesday. I figured I’d probably end up going to the gig so I marked myself as “maybe attending” on the event page on Last.fm.

Fast forward to last week and I’m browsing through the list of upcoming events in Brighton on Last.fm. I see that The Fiery Furnaces will be playing in The Prince Albert on October 7th. When I click through to the event page, this is what I see:

screenshot of Last.fm

Don’t forget you might be going to Fanfarlo at The Hanbury Club on the same date.

That’s nice. That’s really nice. It’s a small touch but it’s the combination of all those small things that adds up to a pleasant experience. This felt …thoughtful.

Of course, it still doesn’t change the fact that I have to choose between Fanfarlo and The Fiery Furnaces.

Fanfarlo — I’m A Pilot on Huffduffer

The Fiery Furnaces — The End is Near on Huffduffer

Machine-tagging Huffduffer some more

After I wrote about the hoops I had to jump through to get Amazon’s API to output JSON (via XSLT), Tom detailed a way of avoiding JSON by using XML-RPC. That’s very kind of him but the truth is that:

  1. I like dealing with JSON and
  2. the XSL transformation is done by Amazon, not me; that wouldn’t be the case if I used XML-RPC.

Anyway, having successfully created a Huffduffer-Amazon bridge using machine tags, I thought I’d do a little more hacking. Instead of restricting the mashup love to Amazon, I figured that Last.fm would be the perfect place to pull in information for anything tagged with the music namespace.

Last.fm has quite a full-featured API and yes, it can output JSON. To start with, I’m using the artist.getInfo method for anything tagged with music:artist=..., music:singer=... or music:band=.... Here are some examples:

I’m pulling a summary of the artist’s bio, a list of similar artists and a picture of the artist in question. For maximum effect, view in Safari, the browser with the finest implementation of .

Nice as Last.fm’s API is, it’s not without its quirks. Like most APIs, the methods are divided into those that require (anything of a sensitive nature) and those that don’t (publicly available information). The method user.getInfo requires authentication. Yet, every piece of information returned by that method is available on the public profile.

So when I wanted to find a Last.fm user’s profile picture—having figured out through when someone on Huffduffer has a Last.fm account—it made far more sense for me to use to parse the microformatted public URL than to use the API method.

Just over two years ago, Drew delivered a superb presentation called In some situations, the answer is definitely “Yes.”

Update: It all ties together, as Julian explains on Twitter:

@adactio ha, I went to Drew’s presentation you mentioned on your blog; it made me add microformats to Last.fm in the first place :D

Hacking Huffduffer with Last.fm

The took place in London yesterday. Much nerdy fun was had by all and some very cool hacks were produced.

Nigel made a neat USB-powered arduino-driven ambient signifier à la availibot that lights up when one of your friends is listening to music. Matt made Songcolours which takes your recently listened-to music, passes the songs through LyricWiki, extracts words that are colours, passes them through the Google chart API and generates a sentence of cut up lyrics (Hannah’s was the best: love drunk home fuck good night). The winning hack, Staff Wars, is a Last.fm-powered quiz that allows people to battle for control of the office stereo—something that could prove very useful at Clearleft.

I knew I’d never be able to compete with the l33t hax0rs in attendance, so I cobbled together a very quick little hack to enhance Huffduffer. I hacked it together fairly quickly which gave me some time to hang out with Hannah in the tragically hip environs of Shoreditch. My hack has one interesting distinguishing feature: it doesn’t make use of the API. Instead, it uses two simpler technologies: microformats and .

  1. Microformats. User profiles on Last.fm are marked up with . If a URL is provided, the user profile also makes use of the most powerful value of : rel="me". If that URL also links back to the Last.fm profile with rel="me"—even if in a roundabout way—that reciprocal link will be picked by Google’s Social Graph API. I’m already making use of that API on Huffduffer to display links to other profiles under the heading Elsewhere. So if someone provides a URL when they sign up to Huffduffer and they’re linking to their social network profiles, I can find out if they use Last.fm and what their username is. The URL structure of user profiles is consistent: http://www.last.fm/user/USERNAME.
  2. RSS. Last.fm provides users with a list of recommended free MP3s. This list is also provided as RSS. More specifically, the RSS feed is a podcast. After all, a podcast is nothing more than an RSS feed that uses enclosures. The URL structure of these podcasts is consistent: http://ws.audioscrobbler.com/2.0/user/USERNAME/podcast.rss.

So if, thanks to magic of XFN, I can figure out someone’s Last.fm username, it’s a simple matter to pull in their recommended music podcast. I’m pulling in the latest three recommended MP3s and displaying them on Huffduffer user profiles under the heading Last.fm recommends. You can see it in action on my Huffduffer profile or the profiles of any other good social citizens like Richard, Tom or Brian.

This isn’t the first little Huffduffer hack I’ve built on top of the Social Graph API. If a Huffduffer user has a Flickr account, their Flickr profile picture is displayed on their Huffduffer profile. When I get some time, I need to expand this little hack to also check for Twitter profiles and grab the profile picture from there as a fallback.

None of these little enhancements are essential features but I like the idea of rewarding people on Huffduffer for their activity on other sites. Ideally I’d like to have Huffduffer’s recommendation engine being partially driven by relationships on third-party sites. So your user profile might suggest something like, You should listen to this because so-and-so huffduffed it; you know one another on Twitter, Flickr, Last.fm…

Next to Last.fm

I’m listening to Jessica play some music on iTunes and I can’t help but think what a shame it is that Last.fm has no knowledge of this. The MyWare of Last.fm only works for my devices; my iTunes, my Mobile Scrobbler. It would be nice if I could somehow let Last.fm know that I’m currently listening to the music of another Last.fm user. It would be even nicer if I didn’t need a computer to do it. Suppose I could just use my mobile phone to send a message to Twitter. Something like:

@lastfm listening to @wordridden

or:

@lastfm scrobbling @wordridden

There would need to be some corresponding method of switching of the link-up. I haven’t really thought it through that far. I’m just jotting down this idea in case anyone out there wants to try using the respective APIs to give this a whirl.

Social networking

Here’s a list of websites on which I have an account and which involve some form of social networking. I’m listing them in order of how often I visit. I’m also listing how many contacts/buddies/friends/connections/people I have on each site.

My Social Networks
WebsiteVisitsConnections
FlickrDaily154
TwitterDaily205
Del.icio.usDaily4
UpcomingFrequently95
Last.fmFrequently66
DopplrFrequently96
JaikuWeekly34
AnobiiWeekly2
CorkdInfrequently27
PownceInfrequently22
RevishInfrequenty9
FicletsInfrequently4
NewsvineInfrequently4
FacebookInfrequently59
Ma.gnoliaRarely7
Linked inRarely90
OdeoRarely10
XingNever2
DiggNever0

This is just a snapshot of activity so some of the data may be slightly skewed. Pownce, for instance, is quite a new site so my visits may increase or decrease dramatically over time. Also, though I’ve listed Del.icio.us as a daily visit, it’s really just the bookmarklet or Adactio Elsewhere that I use every day—I hardly ever visit the site itself.

Other sites that I visit on a daily basis don’t have a social networking component: blogs, news sites, Technorati, The Session (hmmm… must do something about that).

In general, the more often I use a service, the more likely I am to have many connections there. But there are some glaring exceptions. I have hardly any connections on Del.icio.us because the social networking aspect is fairly tangential to the site’s main purpose.

More interestingly, there are some exceptions that run in the other direction. I have lots of connections on Linked in and Facebook but I don’t use them much at all. In the case of Linked in, that’s because I don’t really have any incentive. I’m sure it would be a different story if I were looking for a job.

As for Facebook, I really don’t like the way it tries to be a one-stop shop for everything. It feels like a walled garden to me. I much prefer services that choose to do one thing but do it really well:

Mind you, there’s now some crossover in the events space when the events are musical in nature. The next Salter Cane concert is on Last.fm but it links off to the Upcoming event … which then loops back to Last.fm.

I haven’t settled on a book reading site yet. It’s a toss-up between Anobbii and Revish. It could go either way. One of the deciding factors will be how many of friends use each service. That’s the reason why I use Twitter more than Jaiku. Jaiku is superior in almost every way but more of my friends use Twitter. Inertia keeps me on Twitter. It’s probably just inertia that keeps me Del.icio.us rather than Ma.gnolia.

The sum total of all my connections on all these services comes to 890. But of course most of these are the same people showing up on different sites. I reckon the total amount of individual people doesn’t exceed 250. Of that, there’s probably a core of 50 people who I have connected to on at least 5 services. It’s for these people that I would really, really like to have portable social networks.

Each one of the services I’ve listed should follow these three steps. In order of difficulty:

  1. Provide a publicly addressable list of my connections. Nearly all the sites listed already do this.
  2. Mark up the list of connections with hCard and, where appropriate, XFN. Twitter, Flickr, Ma.gnolia, Pownce, Cork’d and Upcoming already do this.
  3. Provide a form with a field to paste the URL of another service where I have suitably marked-up connections. Parse and attempt to import connections found there.

That last step is the tricky one. Dopplr is the first site to attempt this. That’s the way to do it. Other social networking sites, take note.

It’s time that social networking sites really made an effort to allow not just the free flow of data, but also the free flow of relationships.

Talking with the BBC about microformats

I have now had the pleasure of visiting the BBC. Even though I know a few people who work at the BBC—and many more who used to—I’ve never had the opportunity before to get a look under Auntie Beeb’s new media skirts. Then I got an email asking if I’d be willing to come in and chat about microformats.

I’m always more than willing to rabbit on at length about microformats. Just wind me up and watch me go. It’s particulary pleasurable to natter on to a bunch of smart people working at Europe’s largest website.

There seems to be quite a lot of interest in microformats at the BBC. I spoke in a meeting room packed to the gills with people from a number of different departments. There are quite a few separate areas where people are already experimenting with hCalendar, hCard and rel-tag. Of those, hCalendar is clearly the forerunner: consider that schedule listings are essentially displaying a series of events.

Seeing as I was over at the BBC anyway, I took the opportunity to meet up with Ian for lunch. We compared notes on Hackday and he let me know the the Backstage folks were intrigued by Hackfight. This could be the start of a beautiful friendship.

With my visit to the BBC in East London at end, I hopped on the Central Line all the way across town for a quick visit to the Last.fm HQ. I always like getting a behind-the-scenes look at websites that I make use of on a daily basis. Hannah even managed to take some time out of her busy schedule to go for a coffee—it’s those CBS dollars at work.

All in all, it was a fun day out in London. But I was still glad to get back to Brighton… especially ‘cause I made it back in time for the fun at the Geek Wine Thing. London’s fine in small doses but I wouldn’t want to do that commute every day.

Streaming my life away

I’ve been playing around with Twitter, a neat little service from the people who brought you Odeo. You send it little text updates via SMS, the website, or Jabber. It’s intended as a piece of social software, but I think it has potential for more selfish uses.

Every time I ping Twitter, the message is time stamped. Every time I post a link to Del.icio.us, that’s time stamped. Every time I upload a picture to Flickr, a time stamp of when the picture was taken is also sent. Whenever I listen to a song on iTunes, the track information is sent to Last.fm with a time stamp. And of course whenever I blog, be it here, at the DOM Scripting blog or Principia Gastronomica, each entry has a permalink and a time stamp.

Just about every time somebody publishes something on the Web, it gets time stamped. Wouldn’t it be nice to pull in all these disparate bits of time stamped information and build up a timeline of online activity?

The technology is already in place. Most of the services I mention above have APIs. In this case, a fully-blown API isn’t even necessary. Each service already offers an easily parsable XML file of activity ordered by time: RSS.

At the recent Take Back The Web event here in Brighton, Rob Purdie talked about RSS being the vaseline that’s greasing the wheels of Web 2.0. He makes a good point.

Over the course of any particular day, I could be updating five or six RSS feeds, depending on how much I’m blogging, how many links I’m posting, or how much music I’m listening to. I’d like to take those individual feeds and mush ‘em all up together.

There are a couple of services out there for mashing up RSS. FeedBurner is probably the most well known, but you are limited to a pre-set choice of RSS feeds that you can mix in. RSS Mix offers a more open-ended splicing service but it seems a bit confused when it comes to date ordering. There’s some other service I was playing around with last week but for the life of me, I can’t remember the name of it. All I remember is that it had an extremely annoying interface full of gratuitous Ajax.

I’ve mocked up my own little life stream, tracking my Twitter, Flickr, Del.icio.us, Last.fm, and blog posts. It’s a quick’n’dirty script that isn’t doing any caching. The important thing is that it’s keeping the context of the permalinks (song, link, photo, or blog post) and displaying them ordered by date and time. What I’d really like to do is display the same information in a more time-based interface: a calendar, or timeline.

Annoyingly, the Last.fm feed of recently listened to tracks disappears if you don’t listen to anything for a while. Grrr…

Update: Here’s the PHP source code.

Microformats gone wild

Microformats seem to be showing up in more and more places lately. Chris spotted hCards in the new .mac web client.

Just this week, Last.fm announced a raft of updates including an events section that uses, yes, you guessed it, hCalendar. I did much the same thing when I added events to The Session recently.

I had been eagerly awaiting the unveiling of events (and accompanying microformats) on Last.fm since having a chat with some of the developers at that Opera shindig. I really like the implementation. If you follow through to an individual event, you’ll see some clever use of CSS to auto-generate a gig poster. Nice!

It’ll be interesting to see some mashups of Last.fm with Upcoming. With every event tied to a location, there’s also plenty of room for doing some fun mapping stuff. It would be nice to have an API to access the event data, but having all the events marked up in hCalendar means that we can start playing around with the data anyway.

Thinking about it, gigs are just about the perfect piece of data to play with: there’s always a date and there’s always a geographical location. Surely somebody will build a concert Mapendar?

At the very least, I expect we’ll see a time/location Podbop-style channel on Last.fm before too long.