Ejemplo n.º 1
0
 def __connect(self, username, password, populate_loved=False):
     """
         Connect lastfm
         @param username as str
         @param password as str
         @thread safe
     """
     self.__username = username
     if self.__goa is not None or (password != '' and username != ''):
         self.__is_auth = True
     else:
         self.__is_auth = False
     try:
         self.session_key = ""
         self.__check_for_proxy()
         if self.__goa is not None:
             self.session_key = self.__goa.call_get_access_token_sync(
                                                                   None)[0]
         else:
             skg = SessionKeyGenerator(self)
             self.session_key = skg.get_session_key(
                                               username=self.__username,
                                               password_hash=md5(password))
         if populate_loved:
             self.__populate_loved_tracks()
     except Exception as e:
         debug("Lastfm::__connect(): %s" % e)
         self.__is_auth = False
Ejemplo n.º 2
0
 def __connect(self, full_sync=False):
     """
         Connect service
         @param full_sync as bool
         @thread safe
     """
     if self.__goa is not None or (self.__password != ""
                                   and self.__login != ""):
         self.__is_auth = True
     else:
         self.__is_auth = False
     try:
         self.session_key = ""
         self.__check_for_proxy()
         if self.__goa is not None:
             self.session_key = self.__goa.call_get_access_token_sync(
                 None)[0]
         else:
             skg = SessionKeyGenerator(self)
             self.session_key = skg.get_session_key(username=self.__login,
                                                    password_hash=md5(
                                                        self.__password))
         if full_sync:
             self.__populate_loved_tracks()
     except Exception as e:
         debug("LastFM::__connect(): %s" % e)
         self.__is_auth = False
Ejemplo n.º 3
0
 def __connect(self, username, password, populate_loved=False):
     """
         Connect lastfm
         @param username as str
         @param password as str
         @thread safe
     """
     self.__username = username
     if self.__goa is not None or (password != '' and username != ''):
         self.__is_auth = True
     else:
         self.__is_auth = False
     try:
         self.session_key = ""
         self.__check_for_proxy()
         if self.__goa is not None:
             self.session_key = self.__goa.call_get_access_token_sync(
                                                                   None)[0]
         else:
             skg = SessionKeyGenerator(self)
             self.session_key = skg.get_session_key(
                                               username=self.__username,
                                               password_hash=md5(password))
         if populate_loved:
             self.__populate_loved_tracks()
     except Exception as e:
         debug("Lastfm::__connect(): %s" % e)
         self.__is_auth = False
Ejemplo n.º 4
0
 def __connect(self, full_sync=False):
     """
         Connect service
         @param full_sync as bool
         @thread safe
     """
     if not get_network_available("LASTFM"):
         return
     try:
         self.session_key = ""
         if self.is_goa:
             auth = self.__goa.oauth2_based
             self.api_key = auth.props.client_id
             self.api_secret = auth.props.client_secret
             self.session_key = auth.call_get_access_token_sync(None)[0]
         else:
             skg = SessionKeyGenerator(self)
             self.session_key = skg.get_session_key(username=self.__login,
                                                    password_hash=md5(
                                                        self.__password))
         if full_sync:
             App().task_helper.run(self.__populate_loved_tracks)
         track = App().player.current_track
         self.playing_now(track)
     except Exception as e:
         Logger.debug("LastFM::__connect(): %s" % e)
Ejemplo n.º 5
0
 def authenticate_interactively(self):
     key_gen = SessionKeyGenerator(self.network)
     auth_url = key_gen.get_web_auth_url()
     print("Please auth at: {}".format(auth_url))
     input("Press enter when done...")
     session_key = key_gen.get_web_auth_session_key(auth_url)
     print("Session key is: {} (update your config.py!)".format(session_key))
     return session_key