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 _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
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!
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
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)
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
def get_uri_by_timestamp(cls): """Generate an URI based on the timestamp.""" program = cls._get_selection() if not program: return None # Get a list of addons that can play the selected channel # We do the lookup based on Channel Name, since that's all we have try: addons = cls._get_addons_for_channel(program.get('channel')) except IOError: if kodiutils.yesno_dialog(message=kodiutils.localize( 30713)): # The EPG data is not up to date... from resources.lib.modules.addon import Addon Addon.refresh(True) return None if not addons: # Channel was not found. _LOGGER.debug('No Add-on was found to play %s', program.get('channel')) kodiutils.notification(message=kodiutils.localize( 30710, channel=program.get('channel'))) # Could not find an Add-on... return None if len(addons) == 1: # Channel has one Add-on. Play it directly. _LOGGER.debug('One Add-on was found to play %s: %s', program.get('channel'), addons) return cls._format_uri(list(addons.values())[0], program) # Ask the user to pick an Add-on _LOGGER.debug('Multiple Add-on were found to play %s: %s', program.get('channel'), addons) addons_list = list(addons) ret = kodiutils.select(heading=kodiutils.localize(30711), options=addons_list) # Select an Add-on... if ret == -1: _LOGGER.debug('The selection to play an item from %s was canceled', program.get('channel')) return None return cls._format_uri(addons.get(addons_list[ret]), program)
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()