Last.fm
Having a few spare minutes, I've added a template tag to my site that shows the last 10 songs I've listened to on last.fm.
@register.inclusion_tag('blog/lastfm_tracks.html')
def latest_tracks():
url = 'http://ws.audioscrobbler.com/1.0/user/DReynolds/recenttracks.txt'
response = urllib2.urlopen(url)
songs = []
for line in response.read().split('\n'):
if not re.match(r"^$", line):
songdetail = re.split(",", line)[1]
artist, song = re.split(" \xe2\x80\x93 ", songdetail)
songs.append({'artist' : artist, 'song' : song})
return {'songs' : songs}
Categories: Django, Music, Tech, Web Design
Posted on Wed 25th June 2008 by david
Edited on Wed 25th June 2008

blog comments powered by Disqus