>>> import pylast
#
# all the usual jazz resulting in a Network object
#
>>> user = network.get_user("your username")
>>> events = user.get_upcoming_events()
>>> events[0].get_venue()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/pylast.py", line 1655,
in get_venue
doc = self._request("event.getInfo", True)
File "/usr/local/lib/python2.6/dist-packages/pylast.py", line 969,
in _request
return _Request(self.network, method_name,
params).execute(cacheable)
File "/usr/local/lib/python2.6/dist-packages/pylast.py", line 812,
in execute
response = self._download_response()
File "/usr/local/lib/python2.6/dist-packages/pylast.py", line 803,
in _download_response
self._check_response_for_errors(response_text)
File "/usr/local/lib/python2.6/dist-packages/pylast.py", line 826,
in _check_response_for_errors
raise WSError(self.network, status, details)
pylast.WSError: Invalid event id supplied
Hmm.. this isn't right. Iunno if I'm doing something wrong, or the
pylast library is slightly effed, but what should have worked clearly
didn't.
Luckily, there is another way.
>>> import urllib
>>> user = "YOUR USERNAME HERE"
>>> api_key = "YOUR API KEY HERE"
>>> url = "
http://ws.audioscrobbler.com/2.0/?method=user.getevents&user=%s&api_key=%s" % (user, api_key)
>>> events = urllib.urlopen(url).read()
events is a string, which contains a standard XML-formatted response
to the method call contained in url. From this, you can extract the
information you seek, including the venue names of all the upcoming
concerts. I'm sure the pylast method is easier, but for at least me,
running the latest version of pylast, it doesn't.