Ejemplo n.º 1
0
    def getTags(self, autocorrect=0):
        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorect supplied")

        ret=self._client.call_POST(method='artist.getTags', artist=self._name, autocorrect=autocorrect)
        return [TagRequest(client=self._client, name=xmlutils.extract_subelem(tag, "name").text,
                           url=xmlutils.extract_subelem(tag, "url").text) for tag in
                xmlutils.extract_elems(ret, ".//tags/tag")]
Ejemplo n.º 2
0
    def getCorrection(self):
        ret=self._client.call_GET(method="track.getCorrection", track=self._name, artist=self._artist.getName())

        result=[]
        for track in xmlutils.extract_elems(ret, ".//correction/track"):
            the_name = xmlutils.extract_subelem(track, "name").text
            the_artist = xmlutils.extract_subelem(track, "artist/name").text
            result.append(TrackRequest(client=self._client, name=the_name, artist=the_artist))

        return result
Ejemplo n.º 3
0
    def getTopTags(self, autocorrect=0):
        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="artist.getTopTags", autocorrect=autocorrect, artist=self._name)
        result=[]
        for tag in xmlutils.extract_elems(ret, ".//toptags/tag"):
            name=xmlutils.extract_subelem(tag, ".//name").text
            url=xmlutils.extract_subelem(tag, ".//url").text
            result.append(TagRequest(client=self._client, name=name, url=url))

        return result
Ejemplo n.º 4
0
    def getImages(self, limit=50, autocorrect=0, page=None):
        if limit < 0:
            raise errors.Error("wrong limit supplied")
        if page:
            if page > limit:
                raise errors.Error("wrong page supplied")

        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="artist.getImages", artist=self._name, autocorrect=autocorrect, limit=limit,
                                  page=page)

        result=[]
        for image in xmlutils.extract_elems(ret, ".//images/image"):
            title=xmlutils.extract_subelem(image, "title").text
            title = title if title else ""
            url=xmlutils.extract_subelem(image, "url").text
            dateadded=xmlutils.extract_subelem(image, ".//dateadded").text
            format=xmlutils.extract_subelem(image, ".//format").text
            owner=UserRequest(client=self._client, name=xmlutils.extract_subelem(image, "owner"))
            sizes=[size.text for size in xmlutils.extract_subelems(image, ".//sizes/size")]
            thumbsup=xmlutils.extract_subelem(image, ".//votes/thumbsup").text
            thumbsdown=xmlutils.extract_subelem(image, ".//votes/thumbsdown").text

            result.append(ImageType(title, url, dateadded, format, owner, sizes, thumbsup, thumbsdown))

        return result
Ejemplo n.º 5
0
    def getBuylinks(self,autocorrect=0,country='united kingdom'):
        """contry: A country name, as defined by the ISO 3166-1 country names standard."""

        if autocorrect not in (0,1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="album.getBuylinks",country=country,album=self._name,artist=self._artist,autocorrect=autocorrect)

        result=[]
        for affiliation in xmlutils.extract_elems(ret,".//affiliations/physicals/affiliation"):
                buyLink=xmlutils.extract_subelem(affiliation,".//buyLink").text
                result.append(buyLink)

        for affiliation in xmlutils.extract_elems(ret,".//affiliations/downloads/affiliation"):
                buyLink=xmlutils.extract_subelem(affiliation,".//buyLink").text
                result.append(buyLink)

        return result
Ejemplo n.º 6
0
    def search(self,limit=30,page=1):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        ret=self._client.call_GET(addSign=False,method="album.search",album=self._name,limit=limit,page=page)
        return [AlbumRequest(client=self._client,name=xmlutils.extract_subelem(album,"name").text, artist=xmlutils.extract_subelem(album,"artist")) for album in xmlutils.extract_elems(ret,".//albummatches/album")]
Ejemplo n.º 7
0
    def getSimilar(self,limit=50,autocorrect=0):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if autocorrect not in (0,1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="track.getSimilar",track=self._name,artist=self._artist,limit=limit,autocorrect=autocorrect)
        return [TrackRequest(client=self._client,name=xmlutils.extract_subelem(track,"name").text, artist=xmlutils.extract_subelem(track,"artist/name").text) for track in xmlutils.extract_elems(ret,".//similartracks/track")] 
Ejemplo n.º 8
0
    def search(self,page=1,limit=50):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        res=self._client.call_GET(addSign=False,method="venue.search",venue=self._name,limit=limit,page=page)
        return [EventRequest(client=self._client,id=xmlutils.extract_subelem(event,"id").text) for event in  xmlutils.extract_elems(res,".//results/venuematches/venue")]
Ejemplo n.º 9
0
    def getSimilar(self,limit=50,autocorrect=0):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if autocorrect not in (0,1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(addSign=False,method="artist.getSimilar",artist=self._name,limit=limit,autocorrect=autocorrect)
        return [ArtistRequest(client=self._client,name=xmlutils.extract_subelem(artist,"name").text) for artist in xmlutils.extract_elems(ret,".//similarartists/artist")]
Ejemplo n.º 10
0
    def search(self, limit=30, page=1):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        ret=self._client.call_GET(method="tag.search", tag=self._name, limit=limit, page=page)

        result=[]
        for tag in xmlutils.extract_elems(ret, ".//tagmatches/tag"):
            the_name=xmlutils.extract_subelem(tag, "name").text
            the_url = xmlutils.extract_subelem(tag, "url").text
            if self._name != the_name or self._url != the_url:
                result.append(TagRequest(client=self._client, name=the_name, url=the_url))
            else:
                if self not in result:
                    result.append(self)
Ejemplo n.º 11
0
    def getSimilar(self, limit=50, autocorrect=0):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="track.getSimilar", track=self._name, artist=self._artist.getName(),
                                  limit=limit, autocorrect=autocorrect)

        result=[]
        for track in xmlutils.extract_elems(ret, ".//similartracks/track"):
            the_name=xmlutils.extract_subelem(track, "name").text
            the_artist=xmlutils.extract_subelem(track, "artist/name").text
            if self._artist != the_artist or self._name != the_name:
                result.append(TrackRequest(client=self._client, name=the_name, artist=the_artist))

        return result
Ejemplo n.º 12
0
    def getAttendees(self):
        ret=self._client.call_GET(method="event.getAttendees", event=self._id)

        result=[]
        for user in xmlutils.extract_elems(ret, ".//attendees/user"):
            name=xmlutils.extract_subelem(user, ".//name").text
            result.append(UserRequest(client=self._client, name=name))

        return result
Ejemplo n.º 13
0
    def getPastEvents(self,autocorrect=0,limit=50,page=1):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")
        
        res=self._client.call_GET(method="artist.getPastEvents",artist=self._name,page=page,autocorrect=autocorrect,limit=limit)
        return [EventRequest(client=self._client,id=xmlutils.extract_subelem(event,"id").text) for event in xmlutils.extract_elems(res,".//events/event")]
Ejemplo n.º 14
0
    def getTopAlbums(self, autocorrect=0):
        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="artist.getTopAlbums", autocorrect=autocorrect, artist=self._name)
        result=[]
        for album in xmlutils.extract_elems(ret, ".//topalbums/album"):
            name=xmlutils.extract_subelem(album, ".//name").text
            result.append(AlbumRequest(client=self._client, name=name, artist=self._name))

        return result
Ejemplo n.º 15
0
    def search(self, page=1, limit=50):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        res=self._client.call_GET(method="venue.search", venue=self._name, limit=limit, page=page)

        result = []
        for venue in xmlutils.extract_elems(res, ".//results/venuematches/venue"):
            the_id = xmlutils.extract_subelem(venue, "id").text
            if self._id != the_id:
                the_name = xmlutils.extract_subelem(venue, "name").text
                result.append(VenueRequest(client=self._client, id=the_id, name=the_name))
            else:
                if self not in result:
                    result.append(self)

        return result
Ejemplo n.º 16
0
    def getTopFans(self, autocorrect=0):
        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="artist.getTopFans", autocorrect=autocorrect, artist=self._name)
        result=[]
        for user in xmlutils.extract_elems(ret, ".//topfans/user"):
            name=xmlutils.extract_subelem(user, ".//name").text
            result.append(UserRequest(client=self._client, name=name))

        return result
Ejemplo n.º 17
0
    def getPastEvents(self, page=1, limit=50):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        res=self._client.call_GET(method="venue.getPastEvents", venue=self._id, page=page, limit=limit)

        return [EventRequest(client=self._client, id=xmlutils.extract_subelem(event, "id").text) for event in
                xmlutils.extract_elems(res, ".//events/event")]
Ejemplo n.º 18
0
    def search(self, limit=30, page=1):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        ret=self._client.call_GET(method="album.search", album=self._name, limit=limit, page=page)

        result=[]
        for album in xmlutils.extract_elems(ret, ".//albummatches/album"):
            the_name = xmlutils.extract_subelem(album, "name").text
            the_artist = xmlutils.extract_subelem(album, "artist").text
            if self._name != the_name or self._artist.getName() != the_artist:
                result.append(AlbumRequest(client=self._client, name=the_name, artist=the_artist))
            else:
                if self not in result:
                    result.append(self)

        return result
Ejemplo n.º 19
0
    def search(self,limit=30,page=1,artist=None):
        """artist argument: Narrow your search by specifying an artist."""

        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        artist=artist if artist else self._artist

        ret=self._client.call_GET(method="track.search",track=self._name,artist=artist,limit=limit,page=page)
        return [TrackRequest(client=self._client,name=xmlutils.extract_subelem(track,"name").text, artist=xmlutils.extract_subelem(track,"artist").text) for track in xmlutils.extract_elems(ret,".//trackmatches/track")]
Ejemplo n.º 20
0
    def getSimilar(self, limit=50, autocorrect=0):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if autocorrect not in (0, 1):
            raise errors.Error("wrong autocorrect supplied")

        ret=self._client.call_GET(method="artist.getSimilar", artist=self._name, limit=limit, autocorrect=autocorrect)

        result=[]
        for artist in xmlutils.extract_elems(ret, ".//similarartists/artist"):
            print artist
            the_name = xmlutils.extract_subelem(artist, "name").text
            if self._name != the_name:
                result.append(ArtistRequest(client=self._client, name=the_name))

        return result
Ejemplo n.º 21
0
    def search(self, limit=30, page=1):
        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        ret=self._client.call_GET(method="artist.search", artist=self._name, limit=limit, page=page)

        result=[]
        for artist in xmlutils.extract_elems(ret, ".//artistmatches/artist"):
            the_name = xmlutils.extract_subelem(artist, "name").text
            if self._name != the_name:
                result.append(ArtistRequest(client=self._client, name=the_name))
            else:
                if not self in result:
                    result.append(self)

        return result
Ejemplo n.º 22
0
    def search(self, limit=30, page=1, artist=None):
        """artist argument: Narrow your search by specifying an artist."""

        if limit < 0:
            raise errors.Error("wrong limit supplied")

        if page < 0 or page > limit:
            raise errors.Error("wrong page supplied")

        artist=artist if artist else self._artist

        ret=self._client.call_GET(method="track.search", track=self._name, artist=artist.getName(), limit=limit,
                                  page=page)

        result=[]
        for track in xmlutils.extract_elems(ret, ".//trackmatches/track"):
            the_name= xmlutils.extract_subelem(track, "name").text
            if self._name != the_name:
                result.append(TrackRequest(client=self._client, name = the_name, artist=artist))
            else:
                if self not in result:
                    result.append(self)

        return result
Ejemplo n.º 23
0
 def getTopTags(self):
     ret = self._getInfo()
     return [TagRequest(client=self._client, name=xmlutils.extract_subelem(tag, "name").text,
                        url=xmlutils.extract_subelem(tag, "url").text) for tag in
             xmlutils.extract_elems(ret, ".//toptags/tag")]
Ejemplo n.º 24
0
 def getAlbum(self, autocorrect=0):
     album = xmlutils.extract_elem(self._getInfo(autocorrect=autocorrect), ".//track/album")
     #if album:
     album_name = xmlutils.extract_subelem(album, "title").text
     return AlbumRequest(client=self._client, name=album_name, artist=self._artist.getName())
Ejemplo n.º 25
0
 def getVenue(self):
     res = xmlutils.extract_elem(self._getInfo(), ".//event/venue")
     return VenueRequest(client=self._client, id=xmlutils.extract_subelem(res, "id").text,
                         name=xmlutils.extract_subelem(res, "name").text)
Ejemplo n.º 26
0
def _getTagsHandler(ret):
    return [TagType(xmlutils.extract_subelem(tag,"name").text, xmlutils.extract_subelem(tag,"url").text) for tag in xmlutils.extract_elems(ret,".//tags/tag")]
Ejemplo n.º 27
0
def _getShoutsHandler(ret):
    return [(xmlutils.extract_subelem(shout, "author").text, xmlutils.extract_subelem(shout, "body").text) for shout in
            xmlutils.extract_elems(ret, ".//shouts/shout") ]
Ejemplo n.º 28
0
 def getEvents(self):
     res=self._client.call_GET(method="venue.getEvents", venue=self._id)
     return [EventRequest(client=self._client, id=xmlutils.extract_subelem(event, "id").text) for event in
             xmlutils.extract_elems(res, ".//events/event")]
Ejemplo n.º 29
0
 def getTopTags(self):
     ret = self._getInfo()
     return [TagType(xmlutils.extract_subelem(tag,"name").text, xmlutils.extract_subelem(tag,"url").text) for tag in xmlutils.extract_elems(ret,".//toptags/tag")]