def clicked(self, *ignore): if self.auth_url: def err(e): logging.error(e) self.set_button_text() get_worker().send(self.sg.get_web_auth_session_key, (self.auth_url,), self.setkey, err) self.button.set_label("Checking...") self.button.set_sensitive(False) self.auth_url = False elif self.enabled: self.setkey(False) else: self.network = pylast.get_lastfm_network(api_key=API_KEY, api_secret=API_SECRET) self.sg = pylast.SessionKeyGenerator(self.network) def callback(url): self.auth_url = url self.set_button_text() webbrowser.open(self.auth_url) get_worker().send(self.sg.get_web_auth_url, (), callback) self.button.set_label("Connecting...") self.button.set_sensitive(False)
def connect(self, session_key): self.network = pylast.get_lastfm_network( api_key=API_KEY, api_secret=API_SECRET, session_key = session_key ) self.scrobbler = self.network.get_scrobbler(CLIENT_ID, CLIENT_VERSION)