muh6mm3d / pylast

Automatically exported from code.google.com/p/pylast
Apache License 2.0
0 stars 0 forks source link

get_upcoming_events return venue ID in list #77

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please type example code that produces the issue:
def get_upcoming_events(self):
        """Returns a list of the upcoming Events for this artist."""

        doc = self._request('artist.getEvents', True)

        ids = _extract_all(doc, 'id')

        events = []
        for e_id in ids:
            events.append(Event(e_id, self.network))

        return events

What is the expected output? What do you see instead?
Because the pylast code just calls getElementsByTagName on 'id', the xml 
response not only return the event ID, but also return venue ID. So when you 
iterate through the events and query the event on its ID, it will return 
'Invalid event ID'

What versions of Pylast and Python are you using?

Please provide any additional information below.
How I worked around it:
Instead of getting it by ID, I got a list of all events. Then I traverse 
through the list of events and get the event's ID and append it to the ids list.

def get_upcoming_events(self):
    """Returns a list of the upcoming Events for this artist."""

    doc = self._request('artist.getEvents', True)

    ids = []
    events = doc.getElementsByTagName('event')

    for event in events:
        eventelements = event.childNodes
        eventelements = [event for event in eventelements if event.nodeType == 1]
        for eventelement in eventelements:
        if eventelement.tagName == 'id':
            ids.append(eventelement.firstChild.data)

    events = []
    for e_id in ids:
        events.append(Event(e_id, self.network))

    return events

Original issue reported on code.google.com by wanling....@gmail.com on 2 Apr 2012 at 3:14

GoogleCodeExporter commented 9 years ago
Fixed in my fork: https://github.com/hugovk/pylast/issues/78

Original comment by hugovk@gmail.com on 3 Mar 2014 at 4:47