Exemple #1
0
    def get_xspf_tracks(self):
        """Retrieve xspf tracks from last.fm."""
        xml = self._request(self.url_radio_xspf,
                            sk=self.session_id,
                            desktop=0.1, discovery=0)

        lst = []
        tree = ElementTree.fromstring(xml)
        tracklist = tree.find("trackList")
        for child in tracklist.findall("track"):
            track = Track(to_utf8(child.find("title").text),
                          child.find("id").text)

            track.album = Album(to_utf8(child.find("album").text or ""))
            track.artist = Artist(to_utf8(child.find("creator").text or ""))

            track.url = child.find("location").text
            track.duration = int(child.find("duration").text)
            track.image = child.find("image").text

            lst.append(track)

        return lst
Exemple #2
0
    def get_neighbours(self, username):
        """Retrieve neighbours of a last.fm user.

        @parm username: last.fm username
        """
        url = "%s/%s/neighbours.xml" % (self.url_userfeed, username)
        xml = self._request(url)

        lst = []
        tree = ElementTree.fromstring(xml)
        for child in tree.getchildren():
            neighbour = Neighbour(to_utf8(child.get("username")))
            neighbour.url = child.find("url").text
            neighbour.image = child.find("image").text
            lst.append(neighbour)

        return lst
Exemple #3
0
    def get_friends(self, username):
        """Retrieve friends of a Jamendo user.

        @parm username: Jamendo username
        """
        url = "%s/%s/friends.xml" % (self.url_userfeed, username)
        xml = self._request(url)

        lst = []
        tree = ElementTree.fromstring(xml)
        for child in tree.getchildren():
            friend = Friend(to_utf8(child.get("username")))
            friend.url = child.find("url").text
            friend.image = child.find("image").text
            lst.append(friend)

        return lst