Last.fm/Audioscrobbler provides webservices so that you can get at some
of your music statistics. I wrote a python library to provide easy (in my
eyes) access to the data. The library uses the XML processing library
that comes in the python standard library.
The distribution is set up to be expandable, but the main, and only current
module is scrobxlib. Use import scrobxlib to load it.
Examples
The following are some short simple examples of how to use the library.
In the first example, I request the top artist for a particular user.
In this case, I use myself as an example. Once I have the data, I get the
top artist's name.
>>> import scrobxlib
>>> top_artists = scrobxlib.topArtists( 'phlogistonjohn' )
>>> top_artists[0]['name']
u'Melvins'
>>> # the returned value is a list of dict objects.
>>> top_artists[0]
{'playcount': u'1370', 'url': u'http://www.last.fm/music/Melvins',
'mbid': u'9ccfbc94-a4f4-42f7-b6f5-d903ab77cccb', 'name': u'Melvins',
'rank': u'1'}Here, I want to learn the names of my last.fm friends.
>>> friends = scrobxlib.friends( 'phlogistonjohn' )
>>> [ fr['name'] for fr in friends ]
[u'katmully19', u'pottlukk']
In the last example I will list the names of four artists that are similar
to my top artist, the Melvins.
>>> similar = scrobxlib.similar( 'Melvins' )
>>> [ it['name'] for it in similar[0:4] ]
[u'Fant\xf4mas', u'High on Fire', u'Melvins/Lustmord', u'Kyuss']
NOTE: Special thanks to Mark Woodson for his additions to the library.