def delete_session(self): settings = plexdesktop.settings.Settings() settings.remove('session') settings.remove('user') settings.remove('last_server') self.session = plexdevices.create_session() self.active.emit(False)
def create_session(self, user, passwd): self.working.emit() settings = plexdesktop.settings.Settings() try: logger.debug('SessionManager: creating session') self.session = plexdevices.create_session(user=user, password=passwd) except plexdevices.PlexTVError as e: logger.error('SessionManager: create_session: ' + str(e)) self.done.emit(False, str(e)) else: self.refresh_devices() self.refresh_users() for user in self.session.users: if user.title == self.session.user: settings.setValue('user', user.id) break self.save_session() self.user = self.session.get_user_by_id(settings.value('user')) self.current_server = self.session.get_server_by_id(settings.value('last_server')) if not self.current_server and self.session.servers: self.current_server = self.session.servers[0] self.active.emit(True) self.done.emit(True, '')
def __init__(self, parent=None): super().__init__(parent) self.session = plexdevices.create_session() self.shortcuts = None self.current_server = None self.user = None