How to use the pylast._Search function in pylast

To help you get started, we’ve selected a few pylast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pylast / pylast / pylast.py View on Github external
def __init__(self, venue_name, country_name, network):

        _Search.__init__(self, "venue", {"venue": venue_name, "country": country_name}, network)
github asermax / lastfm_extension / pylast.py View on Github external
_Search.__init__(self, "tag", {"tag": tag_name}, network)
        
    def get_next_page(self):
        """Returns the next page of results as a sequence of Tag objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("tag"):
            tag = Tag(_extract(node, "name"), self.network)
            tag.tag_count = _number(_extract(node, "count"))
            seq.append(tag)
        
        return seq

class TrackSearch(_Search):
    """Search for a track by track title. If you don't wanna narrow the results down
    by specifying the artist name, set it to empty string."""
    
    def __init__(self, artist_name, track_title, network):
        
        _Search.__init__(self, "track", {"track": track_title, "artist": artist_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Track objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("track"):
            track = Track(_extract(node, "artist"), _extract(node, "name"), self.network)
            track.listener_count = _number(_extract(node, "listeners"))
github pylast / pylast / pylast.py View on Github external
_Search.__init__(self, "track", {"track": track_title, "artist": artist_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Track objects."""

        master_node = self._retrieve_next_page()

        seq = []
        for node in master_node.getElementsByTagName("track"):
            track = Track(_extract(node, "artist"), _extract(node, "name"), self.network)
            track.listener_count = _number(_extract(node, "listeners"))
            seq.append(track)

        return seq

class VenueSearch(_Search):
    """Search for a venue by its name. If you don't wanna narrow the results down
    by specifying a country, set it to empty string."""

    def __init__(self, venue_name, country_name, network):

        _Search.__init__(self, "venue", {"venue": venue_name, "country": country_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Track objects."""

        master_node = self._retrieve_next_page()

        seq = []
        for node in master_node.getElementsByTagName("venue"):
            seq.append(Venue(_extract(node, "id"), self.network))
github pylast / pylast / pylast.py View on Github external
_Search.__init__(self, "artist", {"artist": artist_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Artist objects."""

        master_node = self._retrieve_next_page()

        seq = []
        for node in master_node.getElementsByTagName("artist"):
            artist = Artist(_extract(node, "name"), self.network)
            artist.listener_count = _number(_extract(node, "listeners"))
            seq.append(artist)

        return seq

class TagSearch(_Search):
    """Search for a tag by tag name."""

    def __init__(self, tag_name, network):

        _Search.__init__(self, "tag", {"tag": tag_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Tag objects."""

        master_node = self._retrieve_next_page()

        seq = []
        for node in master_node.getElementsByTagName("tag"):
            tag = Tag(_extract(node, "name"), self.network)
            tag.tag_count = _number(_extract(node, "count"))
            seq.append(tag)
github pylast / pylast / pylast.py View on Github external
return _extract(doc, "opensearch:totalResults")

    def _retrieve_page(self, page_index):
        """Returns the node of matches to be processed"""

        params = self._get_params()
        params["page"] = str(page_index)
        doc = self._request(self._ws_prefix + ".search", True, params)

        return doc.getElementsByTagName(self._ws_prefix + "matches")[0]

    def _retrieve_next_page(self):
        self._last_page_index += 1
        return self._retrieve_page(self._last_page_index)

class AlbumSearch(_Search):
    """Search for an album by name."""

    def __init__(self, album_name, network):

        _Search.__init__(self, "album", {"album": album_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Album objects."""

        master_node = self._retrieve_next_page()

        seq = []
        for node in master_node.getElementsByTagName("album"):
            seq.append(Album(_extract(node, "artist"), _extract(node, "name"), self.network))

        return seq
github asermax / lastfm_extension / pylast.py View on Github external
return _extract(doc, "opensearch:totalResults")
    
    def _retreive_page(self, page_index):
        """Returns the node of matches to be processed"""
        
        params = self._get_params()
        params["page"] = str(page_index)
        doc = self._request(self._ws_prefix + ".search", True, params)
        
        return doc.getElementsByTagName(self._ws_prefix + "matches")[0]
    
    def _retrieve_next_page(self):
        self._last_page_index += 1
        return self._retreive_page(self._last_page_index)

class AlbumSearch(_Search):
    """Search for an album by name."""
    
    def __init__(self, album_name, network):
        
        _Search.__init__(self, "album", {"album": album_name}, network)
    
    def get_next_page(self):
        """Returns the next page of results as a sequence of Album objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("album"):
            seq.append(Album(_extract(node, "artist"), _extract(node, "name"), self.network))
        
        return seq
github asermax / lastfm_extension / pylast.py View on Github external
_Search.__init__(self, "track", {"track": track_title, "artist": artist_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Track objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("track"):
            track = Track(_extract(node, "artist"), _extract(node, "name"), self.network)
            track.listener_count = _number(_extract(node, "listeners"))
            seq.append(track)
        
        return seq

class VenueSearch(_Search):
    """Search for a venue by its name. If you don't wanna narrow the results down
    by specifying a country, set it to empty string."""
    
    def __init__(self, venue_name, country_name, network):
        
        _Search.__init__(self, "venue", {"venue": venue_name, "country": country_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Track objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("venue"):
            seq.append(Venue(_extract(node, "id"), self.network))
github asermax / lastfm_extension / pylast.py View on Github external
_Search.__init__(self, "artist", {"artist": artist_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Artist objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("artist"):
            artist = Artist(_extract(node, "name"), self.network)
            artist.listener_count = _number(_extract(node, "listeners"))
            seq.append(artist)
        
        return seq

class TagSearch(_Search):
    """Search for a tag by tag name."""
    
    def __init__(self, tag_name, network):
        
        _Search.__init__(self, "tag", {"tag": tag_name}, network)
        
    def get_next_page(self):
        """Returns the next page of results as a sequence of Tag objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("tag"):
            tag = Tag(_extract(node, "name"), self.network)
            tag.tag_count = _number(_extract(node, "count"))
            seq.append(tag)
github asermax / lastfm_extension / pylast.py View on Github external
def __init__(self, album_name, network):
        
        _Search.__init__(self, "album", {"album": album_name}, network)
    
    def get_next_page(self):
        """Returns the next page of results as a sequence of Album objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("album"):
            seq.append(Album(_extract(node, "artist"), _extract(node, "name"), self.network))
        
        return seq

class ArtistSearch(_Search):
    """Search for an artist by artist name."""
    
    def __init__(self, artist_name, network):
        _Search.__init__(self, "artist", {"artist": artist_name}, network)

    def get_next_page(self):
        """Returns the next page of results as a sequence of Artist objects."""
        
        master_node = self._retrieve_next_page()
        
        seq = []
        for node in master_node.getElementsByTagName("artist"):
            artist = Artist(_extract(node, "name"), self.network)
            artist.listener_count = _number(_extract(node, "listeners"))
            seq.append(artist)