Hi again,
I'm trying to use a python wrapper for the last.fm api. It's pretty old but seems to be working ok (for now). See http://code.google.com/p/pyscrobble/
Anyway, I'm having trouble extracting some information from the output.
import scrobble
user = scrobble.User('mattfeliks') # invoke user class
recent = user.recent_tracks # assign recent_tracks attribute
Now, if I do "print recent", I get this:
matt@ub:~$ python testinglast.py
[(<scrobble.Track(<scrobble.Artist(u'Groove Armada') - u'Hands of Time'), datetime.datetime(2009, 4, 8, 16, 28, 46)), (<scrobble.Track(<scrobble.Artist(u'The Kills') - u'The Good Ones'), datetime.datetime(2009, 4, 8, 16, 25, 14)), (<scrobble.Track(<scrobble.Artist(u'Hoobastank') - u'Ready for You'), datetime.datetime(2009, 4, 8, 16, 22)), (<scrobble.Track(<scrobble.Artist(u'Fairport Convention') - u'Crazy Man Michael'), datetime.datetime(2009, 4, 8, 16, 15, 51)), (<scrobble.Track(<scrobble.Artist(u'Jos\xe9 Gonz\xe1lez') - u'The Nest'), datetime.datetime(2009, 4, 8, 16, 13, 25)), (<scrobble.Track(<scrobble.Artist(u'Son Volt') - u'Drown'), datetime.datetime(2009, 4, 8, 16, 9, 59)))]
and so on...
Now, I would like to just get the "Artist" attribute from this mess. But when I try something like:
for tracks in recent:
print tracks.Track
I keep getting errors along the lines of:
AttributeError: 'tuple' object has no attribute 'Track'
If there is no attribute 'Track', why does it have 'scrobble.Track' in the output?
Am I missing something obvious? Perhaps I need to unpack the tuple?