Beispiel #1
0
    def play_epg_datetime(self, channel, timestamp):
        """ Play a program based on the channel and the timestamp when it was aired
        :type channel: str
        :type timestamp: str
        """
        broadcast = self._vtm_go_epg.get_broadcast(channel, timestamp)
        if not broadcast:
            kodiutils.ok_dialog(heading=kodiutils.localize(30711), message=kodiutils.localize(30713))  # The requested video was not found in the guide.
            kodiutils.end_of_directory()
            return

        kodiutils.redirect(
            kodiutils.url_for('play', category=broadcast.playable_type, item=broadcast.playable_uuid))
Beispiel #2
0
    def login(self):
        """ Start the authorisation flow. """
        auth_info = self._auth.authorize()

        # Show the authorization message
        progress_dialog = kodiutils.progress(
            message=kodiutils.localize(30701,
                                       url=auth_info.get('verification_uri'),
                                       code=auth_info.get('user_code')))
        progress_dialog.update(0)

        # Check the authorization until it succeeds or the user cancels.
        delay = auth_info.get('interval')
        expiry = auth_info.get('expires_in')
        time_start = datetime.now()
        time_end = time_start + timedelta(seconds=expiry)
        while datetime.now() < time_end:
            # Update progress
            progress_dialog.update(
                int((datetime.now() - time_start).seconds * 100 / expiry))

            # Check if the users has cancelled the login flow
            if progress_dialog.iscanceled():
                progress_dialog.close()
                return

            # Check if we are authorized now
            check = self._auth.authorize_check()
            if check:
                progress_dialog.close()
                kodiutils.notification(kodiutils.localize(30702))
                kodiutils.redirect(kodiutils.url_for('show_main_menu'))
                return

            # Sleep a bit
            sleep(delay)

        # Close progress indicator
        progress_dialog.close()

        kodiutils.ok_dialog(message=kodiutils.localize(30703))
    def select_profile(self, key=None):
        """ Show your profiles.

        :type key: str
        """
        profiles = self._auth.get_profiles()

        # Show warning when you have no profiles
        if not profiles:
            # Your account has no profiles defined. Please login on www.streamz.be/streamz 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 = [
            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
Beispiel #4
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