How to use the pylast.User 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 maxexcloo / LastDown / function.py View on Github external
def lastfm_create_session():
	common_log("Last.fm", "Creating Session...")
	global lastfm_user

	# Create Session
	try:
		lastfm_session = pylast.SessionKeyGenerator(lastfm)
		lastfm_session_key = lastfm_session.get_session_key(auth_lastfm_user, pylast.md5(auth_lastfm_pass))
		lastfm_user = pylast.User(auth_lastfm_user, lastfm)
	# Session Error
	except:
		common_log("Critical", "Last.fm Session Creation Failed!")
		sys.exit(0)
github pylast / pylast / pylast.py View on Github external
def __init__(self, user, id, network):
        _BaseObject.__init__(self, network)

        if isinstance(user, User):
            self.user = user
        else:
            self.user = User(user, self.network)

        self.id = id
github maxexcloo / LastDown / pylast.py View on Github external
def get_user(self, username):
        """
            Returns a user object
        """
        
        return User(username, self)
github asermax / lastfm_extension / pylast.py View on Github external
def get_shouts(self, limit=50):
        """
            Returns a sequqence of Shout objects
        """
        
        shouts = []
        for node in _collect_nodes(limit, self, "user.getShouts", False):
            shouts.append(Shout(
                                _extract(node, "body"),
                                User(_extract(node, "author"), self.network),
                                _extract(node, "date")
                                )
                            )
        return shouts
github maxexcloo / LastDown / pylast.py View on Github external
"""
            Returns a sequence of Image objects
            if limit is None it will return all
            order can be IMAGES_ORDER_POPULARITY or IMAGES_ORDER_DATE.
            
            If limit==None, it will try to pull all the available data.
        """
        
        images = []
        
        params = self._get_params()
        params["order"] = order
        nodes = _collect_nodes(limit, self, "artist.getImages", True, params)
        for e in nodes:
            if _extract(e, "name"):
                user = User(_extract(e, "name"), self.network)
            else:
                user = None
                
            images.append(Image(
                            _extract(e, "title"),
                            _extract(e, "url"),
                            _extract(e, "dateadded"),
                            _extract(e, "format"),
                            user,
                            ImageSizes(*_extract_all(e, "size")),
                            (_extract(e, "thumbsup"), _extract(e, "thumbsdown"))
                            )
                        )
        return images
github asermax / lastfm_extension / pylast.py View on Github external
_extract(node, "date")
                                )
                            )
        return shouts
    
    def shout(self, message):
        """
            Post a shout
        """
        
        params = self._get_params()
        params["message"] = message
        
        self._request("user.Shout", False, params)

class AuthenticatedUser(User):
    def __init__(self, network):
        User.__init__(self, "", network);
    
    def _get_params(self):
        return {"user": self.get_name()}
        
    def get_name(self):
        """Returns the name of the authenticated user."""
        
        doc = self._request("user.getInfo", True, {"user": ""})    # hack
        
        self.name = _extract(doc, "name")
        return self.name
        
    def get_recommended_events(self, limit=50):
        """
github asermax / lastfm_extension / pylast.py View on Github external
def get_neighbours(self, limit = 50):
        """Returns a list of the user's friends."""
        
        params = self._get_params()
        if limit:
            params['limit'] = limit
        
        doc = self._request('user.getNeighbours', True, params)
        
        seq = []
        names = _extract_all(doc, 'name')
        
        for name in names:
            seq.append(User(name, self.network))
        
        return seq
github asermax / lastfm_extension / pylast.py View on Github external
def __init__(self, network):
        User.__init__(self, "", network);
github maxexcloo / LastDown / pylast.py View on Github external
def get_friends(self, limit = 50):
        """Returns a list of the user's friends. """
        
        seq = []
        for node in _collect_nodes(limit, self, "user.getFriends", False):
            seq.append(User(_extract(node, "name"), self.network))
        
        return seq
github pylast / pylast / pylast.py View on Github external
def get_shouts(self, limit=50):
        """
            Returns a sequqence of Shout objects
        """

        shouts = []
        for node in _collect_nodes(limit, self, "user.getShouts", False):
            shouts.append(Shout(
                                _extract(node, "body"),
                                User(_extract(node, "author"), self.network),
                                _extract(node, "date")
                                )
                            )
        return shouts