def __init__(self):
     """ Initialise object """
     self._auth = Auth(kodiutils.get_setting('username'),
                       kodiutils.get_setting('password'),
                       kodiutils.get_setting('loginprovider'),
                       kodiutils.get_setting('profile'),
                       kodiutils.get_tokens_path())
Beispiel #2
0
def index():
    """ Show the profile selection, or go to the main menu. """
    auth = Auth(kodiutils.get_tokens_path())
    tokens = auth.get_tokens()

    if tokens:
        select_profile()
    else:
        show_login_menu()
    def verify_credentials():
        """ Verify if the user has credentials and if they are valid. """
        retry = False
        while True:

            # Check if the user has credentials
            if retry or not kodiutils.get_setting(
                    'username') or not kodiutils.get_setting('password'):

                # Ask user to fill in his credentials
                if not kodiutils.yesno_dialog(message=kodiutils.localize(
                        30701)):  # You need to configure your credentials...
                    # The user doesn't want to do this. Abort to Home screen.
                    return False

                kodiutils.open_settings()

            try:
                # Create Auth object so we actually do a login.
                Auth(kodiutils.get_setting('username'),
                     kodiutils.get_setting('password'),
                     kodiutils.get_setting('loginprovider'),
                     kodiutils.get_setting('profile'),
                     kodiutils.get_tokens_path())
                return True

            except InvalidLoginException:
                kodiutils.ok_dialog(message=kodiutils.localize(
                    30203))  # Your credentials are not valid!
                retry = True

            except NoStreamzSubscriptionException:
                kodiutils.ok_dialog(message=kodiutils.localize(
                    30201))  # Your Streamz account has no valid subscription!
                retry = True

            except NoTelenetSubscriptionException:
                kodiutils.ok_dialog(message=kodiutils.localize(
                    30202))  # Your Telenet account has no valid subscription!
                retry = True

            except LoginErrorException as exc:
                kodiutils.ok_dialog(message=kodiutils.localize(
                    30702,
                    code=exc.code))  # Unknown error while logging in: {code}
                return False

            except HTTPError as exc:
                kodiutils.ok_dialog(message=kodiutils.localize(
                    30702, code='HTTP %d' % exc.response.status_code)
                                    )  # Unknown error while logging in: {code}
                return False
Beispiel #4
0
 def __init__(self):
     """ Initialise object """
     self._auth = Auth(kodiutils.get_tokens_path())
Beispiel #5
0
 def __init__(self, ):
     """ Initialise object """
     auth = Auth(kodiutils.get_tokens_path())
     self._api = Api(auth.get_tokens())