Esempio n. 1
0
    def remove_server(self, server_id):
        ''' Stop client and remove server.
        '''
        Jellyfin(server_id).close()
        credentials = get_credentials()

        for server in credentials['Servers']:
            if server['Id'] == server_id:
                credentials['Servers'].remove(server)

                break

        save_credentials(credentials)
        LOG.info("[ remove server ] %s", server_id)
Esempio n. 2
0
    def setup_manual_server(self):
        ''' Setup manual servers
        '''
        client = self.get_client()
        client.set_credentials(get_credentials())
        manager = client.auth

        try:
            self.manual_server(manager)
        except RuntimeError:
            return

        credentials = client.get_credentials()
        save_credentials(credentials)
Esempio n. 3
0
    def setup_login_connect(self):
        ''' Setup emby connect by itself.
        '''
        client = self.get_client()
        client.set_credentials(get_credentials())
        manager = client.auth

        try:
            self.login_connect(manager)
        except RuntimeError:
            return

        credentials = client.get_credentials()
        save_credentials(credentials)
Esempio n. 4
0
    def setup_login_manual(self):
        ''' Setup manual login by itself for default server.
        '''
        client = self.get_client()
        client.set_credentials(get_credentials())
        manager = client.auth

        try:
            self.login_manual(manager=manager)
        except RuntimeError:
            return

        credentials = client.get_credentials()
        save_credentials(credentials)
Esempio n. 5
0
    def set_ssl(self, server_id):
        ''' Allow user to setup ssl verification for additional servers.
        '''
        value = dialog("yesno", heading="{emby}", line1=_(33217))
        credentials = get_credentials()

        for server in credentials['Servers']:

            if server['Id'] == server_id:
                server['verify'] = bool(value)

                break

        save_credentials(credentials)
        LOG.info("[ ssl/%s/%s ]", server_id, server['verify'])
Esempio n. 6
0
    def register(self, server_id=None, options={}):
        ''' Login into server. If server is None, then it will show the proper prompts to login, etc.
            If a server id is specified then only a login dialog will be shown for that server.
        '''
        LOG.info("--[ server/%s ]", server_id or 'default')

        if (server_id) in self.pending:
            LOG.info("[ server/%s ] is already being registered", server_id
                     or 'default')

            return

        self.pending.append(server_id)
        credentials = get_credentials()

        if server_id is None and credentials['Servers']:
            credentials['Servers'] = [credentials['Servers'][0]]

        elif credentials['Servers']:
            for server in credentials['Servers']:

                if server['Id'] == server_id:
                    credentials['Servers'] = [server]

        server_select = True if server_id is None and not settings(
            'SyncInstallRunDone.bool') else False

        try:
            new_credentials = self.register_client(credentials, options,
                                                   server_id, server_select)
            credentials = self._save_servers(new_credentials['Servers'],
                                             server_id is None)
            new_credentials.update(credentials)
            save_credentials(new_credentials)
            Emby(server_id).start(not bool(server_id), True)
        except HTTPException as error:

            if error.status == 'ServerUnreachable':
                self.pending.remove(server_id)

                raise

        except ValueError as error:
            LOG.error(error)

        self.pending.remove(server_id)
Esempio n. 7
0
    def setup_login_manual(self):
        ''' Setup manual login by itself for default server.
        '''
        credentials = get_credentials()
        client = self.get_client(
            credentials['Servers'][0] if credentials['Servers'] else {})
        client.set_credentials(credentials)
        manager = client.auth

        try:
            self.login_manual(manager=manager)
        except RuntimeError:
            return

        new_credentials = client.get_credentials()
        credentials = self._save_servers(new_credentials['Servers'])
        save_credentials(credentials)
Esempio n. 8
0
    def setup_login_connect(self):
        ''' Setup emby connect by itself.
        '''
        credentials = get_credentials()
        client = self.get_client(
            credentials['Servers'][0] if credentials['Servers'] else {})
        client.set_credentials(credentials)
        manager = client.auth

        try:
            self.login_connect(manager)
        except RuntimeError:
            return

        new_credentials = client.get_credentials()
        credentials = self._save_servers(new_credentials['Servers'])
        save_credentials(credentials)
Esempio n. 9
0
    def setup_manual_server(self):
        ''' Setup manual servers
        '''
        credentials = get_credentials()
        client = self.get_client(
            credentials['Servers'][0] if credentials['Servers'] else {})
        client.set_credentials(credentials)
        manager = client.auth

        try:
            self.manual_server(manager)
        except RuntimeError:
            return

        new_credentials = client.get_credentials()
        credentials = self._save_servers(new_credentials['Servers'])
        save_credentials(credentials)
Esempio n. 10
0
    def register(self, server_id=None, options={}):
        ''' Login into server. If server is None, then it will show the proper prompts to login, etc.
            If a server id is specified then only a login dialog will be shown for that server.
        '''
        LOG.info("--[ server/%s ]", server_id or 'default')
        credentials = dict(get_credentials())
        servers = credentials['Servers']

        if server_id is None and credentials['Servers']:
            credentials['Servers'] = [credentials['Servers'][0]]

        elif credentials['Servers']:

            for server in credentials['Servers']:

                if server['Id'] == server_id:
                    credentials['Servers'] = [server]

        server_select = True if server_id is None and not settings(
            'SyncInstallRunDone.bool') else False
        new_credentials = self.register_client(credentials, options, server_id,
                                               server_select)

        for server in servers:
            if server['Id'] == new_credentials['Servers'][0]['Id']:
                server = new_credentials['Servers'][0]

                break
        else:
            servers = new_credentials['Servers']

        credentials['Servers'] = servers
        save_credentials(credentials)

        try:
            Jellyfin(server_id).start(True)
        except ValueError as error:
            LOG.error(error)