How to use the pylast.Artist 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 / tests / test_artist.py View on Github external
def test_bio_summary(self):
        # Arrange
        artist = pylast.Artist("Test Artist", self.network)

        # Act
        bio = artist.get_bio_summary(language="en")

        # Assert
        assert bio is not None
        assert len(bio) >= 1
github motools / LFM-Artist-Similarity-RDF-Service / src / artistlookup.py View on Github external
def getLastFMdata(self, mbid=None):
		'''
		actually get the artist data
		'''

		#if self.Artist == None:
		if self.artistname == None and mbid != None:
			self.Artist = pylast.get_artist_by_mbid(mbid, API_KEY, API_SECRET, self.session_key)
			self.artistname = self.Artist.get_name();
		elif self.artistname != None:
			self.Artist = pylast.Artist(self.artistname, API_KEY, API_SECRET, self.session_key)
		else:
			print "error retrieving artist data - bad name or mbid"
			#sys.exit(2)

		# will actually not fail unti here if there's problems
		try:
			self.similarArtists = self.Artist.get_similar()
		except pylast.ServiceException, msg:
			print "error retrieving artist data - " +str(msg)
			#sys.exit(2)

		# do a bunch of getting
#		try:
#			self.bio = self.Artist.get_bio_content()
#		except pylast.ServiceException, msg:
#			print "error retrieving artist data - " +str(msg)
github maxexcloo / LastDown / pylast.py View on Github external
def get_artist_by_mbid(self, mbid):
        """Loooks up an artist by its MusicBrainz ID"""
        
        params = {"mbid": mbid}
        
        doc = _Request(self, "artist.getInfo", params).execute(True)
        
        return Artist(_extract(doc, "name"), self)
github maxexcloo / LastDown / pylast.py View on Github external
def __init__(self, artist, title, network):
        _BaseObject.__init__(self, network)
        _Taggable.__init__(self, 'track')
        
        if isinstance(artist, Artist):
            self.artist = artist
        else:
            self.artist = Artist(artist, self.network)
        
        self.title = title
github maxexcloo / LastDown / pylast.py View on Github external
def get_artists(self):
        """Returns a list of the participating Artists. """
        
        doc = self._request("event.getInfo", True)
        names = _extract_all(doc, "artist")
        
        artists = []
        for name in names:
            artists.append(Artist(name, self.network))
        
        return artists
github motools / LFM-Artist-Similarity-RDF-Service / src / artistlookup.py View on Github external
def getMBID(self):
		'''check for an mbid to do a redirect'''
		self.Artist = pylast.Artist(self.artistname, API_KEY, API_SECRET, self.session_key)
		return self.Artist.get_mbid()
github pylast / pylast / pylast.py View on Github external
def get_artists(self, limit=50):
        """
        Returns a sequence of Album objects
        if limit==None it will return all (may take a while)
        """

        seq = []
        for node in _collect_nodes(limit, self, "library.getArtists", True):
            name = _extract(node, "name")

            playcount = _number(_extract(node, "playcount"))
            tagcount = _number(_extract(node, "tagcount"))

            seq.append(LibraryItem(Artist(name, self.network), playcount, tagcount))

        return seq
github asermax / lastfm_extension / pylast.py View on Github external
def get_similar(self, limit = None):
        """Returns the similar artists on the network."""
        
        params = self._get_params()
        if limit:
            params['limit'] = limit
        
        doc = self._request('artist.getSimilar', True, params)
        
        names = _extract_all(doc, "name")
        matches = _extract_all(doc, "match")
        
        artists = []
        for i in range(0, len(names)):
            artists.append(SimilarItem(Artist(names[i], self.network), _number(matches[i])))
        
        return artists
github maxexcloo / LastDown / pylast.py View on Github external
params['type1'] = 'user'
        params['type2'] = 'user'
        params['value1'] = self.get_name()
        params['value2'] = user
        
        doc = self._request('tasteometer.compare', False, params)
        
        score = _extract(doc, 'score')
        
        artists = doc.getElementsByTagName('artists')[0]
        shared_artists_names = _extract_all(artists, 'name')
        
        shared_artists_seq = []
        
        for name in shared_artists_names:
            shared_artists_seq.append(Artist(name, self.network))
        
        return (score, shared_artists_seq)
github maxexcloo / LastDown / pylast.py View on Github external
def get_recommended_artists(self, limit=50):
        """
        Returns a sequence of Event objects
        if limit==None it will return all
        """
        
        seq = []
        for node in _collect_nodes(limit, self, "user.getRecommendedArtists", False):
            seq.append(Artist(_extract(node, "name"), self.network))
        
        return seq