Esempio n. 1
0
    def _resolve_stream(uuid):
        """ Resolve the stream for the requested item
        :type uuid: string
        """
        try:
            # Check if we have credentials
            if not kodiutils.get_setting('username') or not kodiutils.get_setting('password'):
                confirm = kodiutils.yesno_dialog(
                    message=kodiutils.localize(30701))  # To watch a video, you need to enter your credentials. Do you want to enter them now?
                if confirm:
                    kodiutils.open_settings()
                kodiutils.end_of_directory()
                return None

            # Fetch an auth token now
            try:
                auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'), kodiutils.get_tokens_path())

                # Get stream information
                resolved_stream = ContentApi(auth).get_stream_by_uuid(uuid)
                return resolved_stream

            except (InvalidLoginException, AuthenticationException) as ex:
                _LOGGER.exception(ex)
                kodiutils.ok_dialog(message=kodiutils.localize(30702, error=str(ex)))
                kodiutils.end_of_directory()
                return None

        except GeoblockedException:
            kodiutils.ok_dialog(message=kodiutils.localize(30710))  # This video is geo-blocked...
            return None

        except UnavailableException:
            kodiutils.ok_dialog(message=kodiutils.localize(30712))  # The video is unavailable...
            return None
Esempio n. 2
0
def index():
    """ Ask to login, or go to the main menu. """
    if not kodiutils.has_credentials():
        if not kodiutils.yesno_dialog(message=kodiutils.localize(
                30701)):  # You need to configure your credentials...
            # We have no credentials, return to the Home Menu
            kodiutils.end_of_directory()
            kodiutils.execute_builtin('ActivateWindow(Home)')
            return

        kodiutils.open_settings()

    try:
        # Try authentication
        AuthApi(username=kodiutils.get_setting('username'),
                password=kodiutils.get_setting('password'),
                tenant=kodiutils.get_setting('tenant'),
                token_path=kodiutils.get_tokens_path())
    except InvalidLoginException:
        kodiutils.ok_dialog(message=kodiutils.localize(
            30203))  # Your credentials are not valid!
        kodiutils.open_settings()
        kodiutils.execute_builtin('ActivateWindow(Home)')
        kodiutils.end_of_directory()
        return

    except HTTPError as exc:
        kodiutils.ok_dialog(message=kodiutils.localize(
            30702, code='HTTP %d' % exc.response.status_code)
                            )  # Unknown error while logging in: {code}
        kodiutils.end_of_directory()
        return

    show_main_menu()
def intro(step=None, credentials_only=False):
    info('Step: {}'.format(step))
    auto_close = 60

    if step is None and get_setting('kraska.user') != '':
        info('Uz nieje treba intro....')
        return
    elif step is None:
        step = 1

    if step == 1:
        start = dyesno(Strings.txt(Strings.INTRO_STEP1_H1),
                       Strings.txt(Strings.INTRO_STEP1_L1),
                       autoclose=auto_close)
        info('RET: [{}] [{}]'.format(start, 'Ano' if start else 'Nie'))
        return intro(step + 1, credentials_only) if start == 1 else 0

    if step == 2:
        user = dinput(Strings.txt(Strings.INTRO_STEP2_H1),
                      get_setting('kraska.user'))
        info(Strings.INTRO_STEP1_H1)
        info(Strings.txt(Strings.INTRO_STEP1_H1))
        info('RET: {}'.format(user))
        settings.set_setting('kraska.user', user)
        if user != settings.get_setting('kraska.user'):
            _remove_settings_file()
            debug('Zmazanie nastaveni')
            return 0

        return intro(step + 1, credentials_only) if user != '' else 0

    if step == 3:
        password = dinput(Strings.txt(Strings.INTRO_STEP3_H1), '')
        info('RET: {}'.format(password))
        settings.set_setting('kraska.pass', password)
        if password != settings.get_setting('kraska.pass'):
            debug('skusam znova zapisat heslo...')
            settings.set_setting('kraska.pass', password)
        kr = Kraska(p=password)
        data = kr.user_info()
        return intro(step +
                     1, credentials_only) if data is False else intro(step + 2)

    if step == 4:
        dok(Strings.txt(Strings.INTRO_STEP4_H1),
            Strings.txt(Strings.INTRO_STEP4_L1))
        return intro(step - 2, credentials_only)

    if step == 5 and credentials_only is False:
        res = dyesno(Strings.txt(Strings.INTRO_STEP5_H1),
                     Strings.txt(Strings.INTRO_STEP5_L1))
        if res:
            open_settings('1.0')
    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
Esempio n. 5
0
    def play(item):
        """ Play the requested item.
        :type item: string
        """

        # Workaround for Raspberry Pi 3 and older
        omxplayer = kodiutils.get_global_setting('videoplayer.useomxplayer')
        if omxplayer is False:
            kodiutils.set_global_setting('videoplayer.useomxplayer', True)

        try:
            # Check if we have credentials
            if not kodiutils.get_setting(
                    'username') or not kodiutils.get_setting('password'):
                confirm = kodiutils.yesno_dialog(
                    message=kodiutils.localize(30701)
                )  # To watch a video, you need to enter your credentials. Do you want to enter them now?
                if confirm:
                    kodiutils.open_settings()
                kodiutils.end_of_directory()
                return

            # Fetch an auth token now
            try:
                auth = AuthApi(kodiutils.get_setting('username'),
                               kodiutils.get_setting('password'),
                               kodiutils.get_tokens_path())

                # Get stream information
                resolved_stream = ContentApi(auth).get_stream_by_uuid(item)

            except (InvalidLoginException, AuthenticationException) as ex:
                _LOGGER.error(ex)
                kodiutils.ok_dialog(
                    message=kodiutils.localize(30702, error=str(ex)))
                kodiutils.end_of_directory()
                return

        except GeoblockedException:
            kodiutils.ok_dialog(heading=kodiutils.localize(30709),
                                message=kodiutils.localize(
                                    30710))  # This video is geo-blocked...
            return

        except UnavailableException:
            kodiutils.ok_dialog(heading=kodiutils.localize(30711),
                                message=kodiutils.localize(
                                    30712))  # The video is unavailable...
            return

        # Play this item
        kodiutils.play(resolved_stream)
Esempio n. 6
0
    def _check_credentials():
        """ Check if the user has credentials """
        if kodiutils.has_credentials():
            return True

        # You need to configure your credentials before you can access the content of VTM GO.
        confirm = kodiutils.yesno_dialog(message=kodiutils.localize(30701))
        if confirm:
            kodiutils.open_settings()
            if kodiutils.has_credentials():
                return True

        return False
Esempio n. 7
0
def setup_iptv_simple():
    """Setup IPTV Simple"""
    reply = kodiutils.yesno_dialog(
        message=kodiutils.localize(30700))  # Are you sure...
    if reply:
        if IptvSimple.setup():
            kodiutils.ok_dialog(message=kodiutils.localize(
                30701))  # The configuration of IPTV Simple is completed!
        else:
            kodiutils.ok_dialog(message=kodiutils.localize(
                30702))  # The configuration of IPTV Simple has failed!

    # Open settings again
    kodiutils.open_settings()
Esempio n. 8
0
def index():
    """ Show the profile selection, or go to the main menu. """
    while True:
        if not kodiutils.has_credentials():
            if not kodiutils.yesno_dialog(message=kodiutils.localize(
                    30701)):  # You need to configure your credentials...
                # We have no credentials
                kodiutils.end_of_directory()
                kodiutils.execute_builtin('ActivateWindow(Home)')
                return

            kodiutils.open_settings()
        else:
            break

    try:
        if kodiutils.get_setting_bool('auto_login') and kodiutils.get_setting(
                'profile'):
            # We have a profile
            show_main_menu()

        else:
            # Ask the user for the profile to use
            select_profile()

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

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

    except HTTPError as exc:
        kodiutils.ok_dialog(message=kodiutils.localize(
            30702, code='HTTP %d' % exc.response.status_code)
                            )  # Unknown error while logging in: {code}
        kodiutils.end_of_directory()
Esempio n. 9
0
def index():
    """ Show the profile selection, or go to the main menu. """
    try:
        if (kodiutils.get_setting_bool('auto_login')
                and kodiutils.get_setting('username')
                and kodiutils.get_setting('password')
                and kodiutils.get_setting('profile')):
            # We have credentials
            show_main_menu()

        else:
            # Ask the user for the profile to use
            select_profile()

    except NoLoginException:
        kodiutils.ok_dialog(message=kodiutils.localize(
            30701))  # You need to configure your credentials...
        kodiutils.open_settings()
        kodiutils.container_refresh()

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

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

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

    except LoginErrorException as exc:
        kodiutils.ok_dialog(message=kodiutils.localize(
            30702, code=exc.code))  # Unknown error while logging in: {code}
        kodiutils.open_settings()
        kodiutils.end_of_directory()
Esempio n. 10
0
    def select_profile(self, key=None):  # pylint: disable=too-many-return-statements
        """ Show your profiles
        :type key: str
        """
        try:
            profiles = self._auth.get_profiles()
        except InvalidLoginException:
            kodiutils.ok_dialog(message=kodiutils.localize(
                30203))  # Your credentials are not valid!
            kodiutils.open_settings()
            return

        except InvalidTokenException:
            self._auth.logout()
            kodiutils.redirect(kodiutils.url_for('select_profile'))
            return

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

        except ApiUpdateRequired:
            kodiutils.ok_dialog(message=kodiutils.localize(
                30705))  # The VTM GO Service has been updated...
            return

        except Exception as exc:  # pylint: disable=broad-except
            kodiutils.ok_dialog(message="%s" % exc)
            return

        # Show warning when you have no profiles
        if not profiles:
            # Your account has no profiles defined. Please login on vtm.be/vtmgo and create a Profile.
            kodiutils.ok_dialog(message=kodiutils.localize(30703))
            kodiutils.end_of_directory()
            return

        # Select the first profile when you only have one
        if len(profiles) == 1:
            key = profiles[0].key

        # Save the selected profile
        if key:
            profile = [x for x in profiles if x.key == key][0]
            _LOGGER.debug('Setting profile to %s', profile)
            kodiutils.set_setting('profile',
                                  '%s:%s' % (profile.key, profile.product))
            kodiutils.set_setting('profile_name', profile.name)

            kodiutils.redirect(kodiutils.url_for('show_main_menu'))
            return

        # Show profile selection when you have multiple profiles
        listing = [
            kodiutils.TitleItem(
                title=self._get_profile_name(p),
                path=kodiutils.url_for('select_profile', key=p.key),
                art_dict=dict(icon='DefaultUser.png'),
                info_dict=dict(plot=p.name, ),
            ) for p in profiles
        ]

        kodiutils.show_listing(listing, sort=['unsorted'],
                               category=30057)  # Select Profile
Esempio n. 11
0
def open_settings():
    """Open the settings for IPTV Manager"""
    kodiutils.open_settings()
Esempio n. 12
0
def refresh():
    """Refresh the channels and EPG"""
    Addon.refresh(True)

    # Open settings again
    kodiutils.open_settings()