def login(ask_credentials=True): """Perform a login""" try: credentials = None is_login_with_credentials = True if ask_credentials: is_login_with_credentials = ui.show_yesno_dialog( 'Login', common.get_local_string(30340), yeslabel=common.get_local_string(30341), nolabel=common.get_local_string(30342)) if is_login_with_credentials: credentials = {'credentials': ui.ask_credentials()} if is_login_with_credentials: if common.make_call('login', credentials): return True else: data = common.run_nf_authentication_key() if not data: raise MissingCredentialsError password = ui.ask_for_password() if password and common.make_call('login_auth_data', { 'data': data, 'password': password }): return True except MissingCredentialsError: # Aborted from user or leave an empty field ui.show_notification(common.get_local_string(30112)) raise except LoginError as exc: # Login not valid ui.show_ok_dialog(common.get_local_string(30008), str(exc)) return False
def _perform_addon_changes(previous_ver, current_ver): """Perform actions for an version bump""" from resources.lib.common import (debug, is_less_version) debug('Initialize addon upgrade operations, from version {} to {})', previous_ver, current_ver) if previous_ver and is_less_version(previous_ver, '0.15.9'): import resources.lib.kodi.ui as ui msg = ( 'This update resets the settings to auto-update library.\r\n' 'Therefore only in case you are using auto-update must be reconfigured.' ) ui.show_ok_dialog('Netflix upgrade', msg) if previous_ver and is_less_version(previous_ver, '0.16.0'): import resources.lib.kodi.ui as ui msg = ( 'Has been introduced watched status marks for the videos separate for each profile:\r\n' '[Use new feature] watched status will be separate by profile, [B]existing watched status will be lost.[/B]\r\n' '[Leave unchanged] existing watched status will be kept, [B]but in future versions will be lost.[/B]\r\n' 'This option can be temporarily changed in expert settings') choice = ui.show_yesno_dialog('Netflix upgrade - watched status marks', msg, 'Use new feature', 'Leave unchanged') g.settings_monitor_suspend(at_first_change=True) g.ADDON.setSettingBool('watched_status_by_profile', choice) # Clear cache (prevents problems when netflix change data structures) g.CACHE.invalidate(True) # Always leave this to last - After the operations set current version g.LOCAL_DB.set_value('addon_previous_version', current_ver)
def show_availability_message(self, videoid): # pylint: disable=unused-argument """Show a message to the user to show the date of availability of a video""" # Try get the promo trailer path trailer_path = xbmc.getInfoLabel('ListItem.Trailer') msg = common.get_local_string(30620).format( xbmc.getInfoLabel('ListItem.Property(nf_availability_message)') or '--') if trailer_path: if ui.show_yesno_dialog(xbmc.getInfoLabel('ListItem.Label'), msg + '[CR]' + common.get_local_string(30621), default_yes_button=True): # Create a basic trailer ListItem (all other info if available are set on Play callback) list_item = xbmcgui.ListItem( xbmc.getInfoLabel('ListItem.Title'), offscreen=True) list_item.setInfo( 'video', {'Title': xbmc.getInfoLabel('ListItem.Title')}) list_item.setProperty('isPlayable', 'true') xbmc.Player().play(trailer_path, list_item) else: ui.show_ok_dialog(xbmc.getInfoLabel('ListItem.Label'), msg)