Exemplo n.º 1
0
 def create_server_account(cls):
     try:
         Account.get(Account.id == 0)
     except Account.DoesNotExist:
         Account.create(
             id=0,
             name=''
         )
Exemplo n.º 2
0
    def create_administrator_account(cls, token_plex=None):
        username = cls.get_trakt_username()

        try:
            account = Account.get(Account.id == 1)
        except Account.DoesNotExist:
            account = Account.create(
                id=1,
                name=username
            )

            # Create default rules for account
            cls.create_rules(account)

        # Ensure plex account details exist
        p_created, p_account = cls.create_plex_account(account)

        cls.create_plex_basic_credential(p_account, token_plex=token_plex)

        # Refresh plex account details
        try:
            p_refreshed = p_account.refresh(force=p_created)
        except:
            log.warn('Unable to refresh plex account (not authenticated?)', exc_info=True)
            p_refreshed = False

        # Ensure trakt account details exist
        t_created, t_account = cls.create_trakt_account(account, username)

        cls.create_trakt_basic_credential(t_account)
        cls.create_trakt_oauth_credential(t_account)

        # Refresh trakt account details
        try:
            t_refreshed = t_account.refresh(force=t_created)
        except:
            log.warn('Unable to refresh trakt account (not authenticated?)', exc_info=True)
            t_refreshed = False

        # Refresh account
        account.refresh(force=p_refreshed or t_refreshed)
Exemplo n.º 3
0
    def create_administrator_account(cls, token_plex=None):
        username = cls.get_trakt_username()

        try:
            account = Account.get(Account.id == 1)
        except Account.DoesNotExist:
            account = Account.create(id=1, name=username)

            # Create default rules for account
            cls.create_rules(account)

        # Ensure plex account details exist
        p_created, p_account = cls.create_plex_account(account)

        cls.create_plex_basic_credential(p_account, token_plex=token_plex)

        # Refresh plex account details
        try:
            p_refreshed = p_account.refresh(force=p_created)
        except:
            log.warn('Unable to refresh plex account (not authenticated?)',
                     exc_info=True)
            p_refreshed = False

        # Ensure trakt account details exist
        t_created, t_account = cls.create_trakt_account(account, username)

        cls.create_trakt_basic_credential(t_account)
        cls.create_trakt_oauth_credential(t_account)

        # Refresh trakt account details
        try:
            t_refreshed = t_account.refresh(force=t_created)
        except:
            log.warn('Unable to refresh trakt account (not authenticated?)',
                     exc_info=True)
            t_refreshed = False

        # Refresh account
        account.refresh(force=p_refreshed or t_refreshed)
Exemplo n.º 4
0
 def create_server_account(cls):
     try:
         Account.get(Account.id == 0)
     except Account.DoesNotExist:
         Account.create(id=0, name='')