def run(argv): # Initialize globals right away to avoid stale values from the last addon invocation. # Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior! # PR: https://github.com/xbmc/xbmc/pull/13814 g.init_globals(argv) check_service_upgrade() NetflixService().run()
def run(argv): # pylint: disable=broad-except,ungrouped-imports # Initialize globals right away to avoid stale values from the last addon invocation. # Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior! # PR: https://github.com/xbmc/xbmc/pull/13814 g.init_globals(argv) reset_log_level_global_var() info('Started (Version {})'.format(g.VERSION_RAW)) info('URL is {}'.format(g.URL)) success = True window_cls = Window(10000) # Kodi home window # If you use multiple Kodi profiles you need to distinguish the property of current profile prop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name()) is_external_call = _check_addon_external_call(window_cls, prop_nf_service_status) service_status = _get_service_status(window_cls, prop_nf_service_status) if service_status.get('status') != 'running': if not is_external_call: if service_status.get('status') == 'error': # The services are not started due to an error exception from resources.lib.kodi.ui import show_error_info show_error_info( get_local_string(30105), get_local_string(30240).format( service_status.get('message')), False, False) else: # The services are not started yet from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False if success: try: if _check_valid_credentials(): if g.IS_ADDON_FIRSTRUN: if check_addon_upgrade(): from resources.lib.config_wizard import run_addon_configuration run_addon_configuration() route([part for part in g.PATH.split('/') if part]) else: success = False except BackendNotReady: from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False except Exception as exc: import traceback from resources.lib.kodi.ui import show_addon_error_info error(g.py2_decode(traceback.format_exc(), 'latin-1')) show_addon_error_info(exc) success = False if not success: _handle_endofdirectory() log_time_trace()
def _on_change(self): common.debug( 'SettingsMonitor: Settings changed, reinitialize global settings') req_sort_order_type_oldvalue = g.REQ_SORT_ORDER_TYPE g.init_globals(sys.argv) if g.REQ_SORT_ORDER_TYPE != req_sort_order_type_oldvalue: # We remove the cache to allow get the new results in the chosen order common.run_plugin( 'plugin://plugin.video.netflix/action/purge_cache/?on_disk=True&no_notification=True' ) ps_changed = False for menu_id, data in g.MAIN_MENU_ITEMS.iteritems(): new_setting = bool( g.ADDON.getSettingBool('_'.join(('show_menu', menu_id)))) old_setting = g.PERSISTENT_STORAGE['show_menus'].get(menu_id, True) if new_setting != old_setting: g.PERSISTENT_STORAGE['show_menus'][menu_id] = new_setting ps_changed = True if ps_changed: g.PERSISTENT_STORAGE.commit() url = 'plugin://plugin.video.netflix/directory/root' xbmc.executebuiltin('Container.Update({},replace)'.format(url))
def run(argv): # pylint: disable=broad-except,ungrouped-imports # Initialize globals right away to avoid stale values from the last addon invocation. # Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior! # PR: https://github.com/xbmc/xbmc/pull/13814 g.init_globals(argv) reset_log_level_global_var() info('Started (Version {})'.format(g.VERSION)) info('URL is {}'.format(g.URL)) success = True window_cls = Window(10000) # Kodi home window # If you use multiple Kodi profiles you need to distinguish the property of current profile prop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name()) is_widget_skin_call = _skin_widget_call(window_cls, prop_nf_service_status) if window_cls.getProperty(prop_nf_service_status) != 'running': if not is_widget_skin_call: from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False if success: try: if _check_valid_credentials(): if g.IS_ADDON_FIRSTRUN: check_addon_upgrade() g.initial_addon_configuration() if not is_widget_skin_call: update_cache_videoid_runtime(window_cls) route([part for part in g.PATH.split('/') if part]) else: success = False except BackendNotReady: from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False except Exception as exc: import traceback from resources.lib.kodi.ui import show_addon_error_info error(traceback.format_exc()) show_addon_error_info(exc) success = False if not success: _handle_endofdirectory() g.CACHE.commit() log_time_trace()
def run(argv): # pylint: disable=broad-except,ungrouped-imports # Initialize globals right away to avoid stale values from the last addon invocation. # Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior! # PR: https://github.com/xbmc/xbmc/pull/13814 g.init_globals(argv) reset_log_level_global_var() info('Started (Version {})'.format(g.VERSION)) info('URL is {}'.format(g.URL)) success = True window_cls = Window(10000) if not bool(window_cls.getProperty('is_service_running')): from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False if success: try: if _check_valid_credentials(): check_addon_upgrade() g.initial_addon_configuration() route([part for part in g.PATH.split('/') if part]) except BackendNotReady: from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False except Exception as exc: import traceback from resources.lib.kodi.ui import show_addon_error_info error(traceback.format_exc()) show_addon_error_info(exc) success = False if not success: _handle_endofdirectory() g.CACHE.commit() log_time_trace()
def _on_change(self): common.debug('SettingsMonitor: Settings changed, reinitialize global settings') g.init_globals(sys.argv) ps_changed = False show_menu_changed = False sort_order_type_changed = False for menu_id, menu_data in g.MAIN_MENU_ITEMS.iteritems(): # Check settings changes in show menu show_menu_new_setting = bool(g.ADDON.getSettingBool('_'.join(('show_menu', menu_id)))) show_menu_old_setting = g.PERSISTENT_STORAGE['show_menus'].get(menu_id, True) if show_menu_new_setting != show_menu_old_setting: g.PERSISTENT_STORAGE['show_menus'][menu_id] = show_menu_new_setting show_menu_changed = True ps_changed = True # Check settings changes in sort order of menu if menu_data.get('request_context_name'): menu_sortorder_new_setting = int( g.ADDON.getSettingInt('_'.join(('menu_sortorder', menu_data['path'][1])))) menu_sortorder_old_setting = g.PERSISTENT_STORAGE['menu_sortorder'].get(menu_id, 0) if menu_sortorder_new_setting != menu_sortorder_old_setting: g.PERSISTENT_STORAGE['menu_sortorder'][menu_id] = menu_sortorder_new_setting sort_order_type_changed = True ps_changed = True if ps_changed: g.PERSISTENT_STORAGE.commit() if sort_order_type_changed: # We remove the cache to allow get the new results in the chosen order common.run_plugin('plugin://plugin.video.netflix/action/purge_cache/?on_disk=True&no_notification=True') if show_menu_changed: url = 'plugin://plugin.video.netflix/directory/root' xbmc.executebuiltin('Container.Update({},replace)'.format(url))
def _on_change(self): common.reset_log_level_global_var() common.debug( 'SettingsMonitor: settings have been changed, started checks') reboot_addon = False clean_cache = False use_mysql = g.ADDON.getSettingBool('use_mysql') use_mysql_old = g.LOCAL_DB.get_value('use_mysql', False, TABLE_SETTINGS_MONITOR) use_mysql_turned_on = use_mysql and not use_mysql_old common.debug( 'SettingsMonitor: Reinitialization of service global settings') g.init_globals(sys.argv, use_mysql != use_mysql_old) # Check the MySQL connection status after reinitialization of service global settings use_mysql_after = g.ADDON.getSettingBool('use_mysql') if use_mysql_turned_on and use_mysql_after: g.LOCAL_DB.set_value('use_mysql', True, TABLE_SETTINGS_MONITOR) ui.show_notification(g.ADDON.getLocalizedString(30202)) if not use_mysql_after and use_mysql_old: g.LOCAL_DB.set_value('use_mysql', False, TABLE_SETTINGS_MONITOR) _esn_checks() # Check menu settings changes for menu_id, menu_data in iteritems(g.MAIN_MENU_ITEMS): # Check settings changes in show/hide menu if menu_data.get('has_show_setting', True): show_menu_new_setting = bool( g.ADDON.getSettingBool('_'.join(('show_menu', menu_id)))) show_menu_old_setting = g.LOCAL_DB.get_value( 'menu_{}_show'.format(menu_id), True, TABLE_SETTINGS_MONITOR) if show_menu_new_setting != show_menu_old_setting: g.LOCAL_DB.set_value('menu_{}_show'.format(menu_id), show_menu_new_setting, TABLE_SETTINGS_MONITOR) reboot_addon = True # Check settings changes in sort order of menu if menu_data.get('has_sort_setting'): menu_sortorder_new_setting = int( g.ADDON.getSettingInt('menu_sortorder_' + menu_data['path'][1])) menu_sortorder_old_setting = g.LOCAL_DB.get_value( 'menu_{}_sortorder'.format(menu_id), 0, TABLE_SETTINGS_MONITOR) if menu_sortorder_new_setting != menu_sortorder_old_setting: g.LOCAL_DB.set_value('menu_{}_sortorder'.format(menu_id), menu_sortorder_new_setting, TABLE_SETTINGS_MONITOR) # We remove the cache to allow get the new results in the chosen order g.CACHE.clear([CACHE_COMMON, CACHE_MYLIST, CACHE_SEARCH]) # Check changes on content profiles # This is necessary because it is possible that some manifests # could be cached using the previous settings (see msl_handler - load_manifest) menu_keys = [ 'enable_dolby_sound', 'enable_vp9_profiles', 'enable_hevc_profiles', 'enable_hdr_profiles', 'enable_dolbyvision_profiles', 'enable_force_hdcp', 'disable_webvtt_subtitle' ] collect_int = '' for menu_key in menu_keys: collect_int += unicode(int(g.ADDON.getSettingBool(menu_key))) collect_int_old = g.LOCAL_DB.get_value('content_profiles_int', '', TABLE_SETTINGS_MONITOR) if collect_int != collect_int_old: g.LOCAL_DB.set_value('content_profiles_int', collect_int, TABLE_SETTINGS_MONITOR) g.CACHE.clear([CACHE_MANIFESTS]) # Check if Progress Manager settings is changed progress_manager_enabled = g.ADDON.getSettingBool( 'ProgressManager_enabled') progress_manager_enabled_old = g.LOCAL_DB.get_value( 'progress_manager_enabled', False, TABLE_SETTINGS_MONITOR) if progress_manager_enabled != progress_manager_enabled_old: g.LOCAL_DB.set_value('progress_manager_enabled', progress_manager_enabled, TABLE_SETTINGS_MONITOR) common.send_signal(signal=common.Signals.SWITCH_EVENTS_HANDLER, data=progress_manager_enabled) # Avoid perform these operations when the add-on is installed from scratch and there are no credentials if (clean_cache or reboot_addon) and not common.check_credentials(): reboot_addon = False if reboot_addon: common.debug('SettingsMonitor: addon will be rebooted') # Open root page common.container_update( common.build_url(['root'], mode=g.MODE_DIRECTORY))
def run(argv): # pylint: disable=broad-except,ungrouped-imports,too-many-branches # Initialize globals right away to avoid stale values from the last addon invocation. # Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior! # PR: https://github.com/xbmc/xbmc/pull/13814 g.init_globals(argv) reset_log_level_global_var() info('Started (Version {})'.format(g.VERSION_RAW)) info('URL is {}'.format(g.URL)) success = True window_cls = Window(10000) # Kodi home window # If you use multiple Kodi profiles you need to distinguish the property of current profile prop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name()) is_external_call = _check_addon_external_call(window_cls, prop_nf_service_status) service_status = _get_service_status(window_cls, prop_nf_service_status) if service_status.get('status') != 'running': if not is_external_call: if service_status.get('status') == 'error': # The services are not started due to an error exception from resources.lib.kodi.ui import show_error_info show_error_info( get_local_string(30105), get_local_string(30240).format( service_status.get('message')), False, False) else: # The services are not started yet from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False if success: try: if _check_valid_credentials(): if g.IS_ADDON_FIRSTRUN: if check_addon_upgrade(): from resources.lib.config_wizard import run_addon_configuration run_addon_configuration() route([part for part in g.PATH.split('/') if part]) else: success = False except BackendNotReady: from resources.lib.kodi.ui import show_backend_not_ready show_backend_not_ready() success = False except InputStreamHelperError as exc: from resources.lib.kodi.ui import show_ok_dialog show_ok_dialog('InputStream Helper Add-on error', ( 'The operation has been cancelled.\r\n' 'InputStream Helper has generated an internal error:\r\n{}\r\n\r\n' 'Please report it to InputStream Helper github.'.format(exc))) success = False except HttpError401: # Http error 401 Client Error: Unauthorized for url ... issue (see _request in nfsession_requests.py) from resources.lib.kodi.ui import show_ok_dialog show_ok_dialog(get_local_string(30105), ( 'There was a communication problem with Netflix.\r\n' 'This is a known and unresolvable issue, do not submit reports.\r\n' 'You can try the operation again or exit.')) success = False except Exception as exc: import traceback from resources.lib.kodi.ui import show_addon_error_info error(g.py2_decode(traceback.format_exc(), 'latin-1')) show_addon_error_info(exc) success = False if not success: _handle_endofdirectory() log_time_trace()
# Created on: 13.01.2017 # License: MIT https://goo.gl/5bMj3H # pylint: disable=wrong-import-position """Kodi plugin for Netflix (https://netflix.com)""" from __future__ import unicode_literals import sys from functools import wraps import xbmcplugin # Import and intiliaze globals right away to avoid stale values from the last # addon invocation. Otherwise Kodi's reuseLanguageInvoker will caus some # really quirky behavior! from resources.lib.globals import g g.init_globals(sys.argv) import resources.lib.common as common import resources.lib.api.shakti as api import resources.lib.kodi.ui as ui import resources.lib.navigation as nav import resources.lib.navigation.directory as directory import resources.lib.navigation.hub as hub import resources.lib.navigation.player as player import resources.lib.navigation.actions as actions import resources.lib.navigation.library as library from resources.lib.api.exceptions import NotLoggedInError NAV_HANDLERS = { g.MODE_DIRECTORY: directory.DirectoryBuilder,
def _on_change(self): common.reset_log_level_global_var() common.debug( 'SettingsMonitor: settings have been changed, started checks') reboot_addon = False clean_cache = False use_mysql = g.ADDON.getSettingBool('use_mysql') use_mysql_old = g.LOCAL_DB.get_value('use_mysql', False, TABLE_SETTINGS_MONITOR) use_mysql_turned_on = use_mysql and not use_mysql_old common.debug( 'SettingsMonitor: Reinitialization of service global settings') g.init_globals(sys.argv, use_mysql != use_mysql_old) # Check the MySQL connection status after reinitialization of service global settings use_mysql_after = g.ADDON.getSettingBool('use_mysql') if use_mysql_turned_on and use_mysql_after: g.LOCAL_DB.set_value('use_mysql', True, TABLE_SETTINGS_MONITOR) ui.show_notification(g.ADDON.getLocalizedString(30202)) if not use_mysql_after and use_mysql_old: g.LOCAL_DB.set_value('use_mysql', False, TABLE_SETTINGS_MONITOR) # Check if the custom esn is changed custom_esn = g.ADDON.getSetting('esn') custom_esn_old = g.LOCAL_DB.get_value('custom_esn', '', TABLE_SETTINGS_MONITOR) if custom_esn != custom_esn_old: g.LOCAL_DB.set_value('custom_esn', custom_esn, TABLE_SETTINGS_MONITOR) common.send_signal(signal=common.Signals.ESN_CHANGED, data=g.get_esn()) # Check menu settings changes for menu_id, menu_data in iteritems(g.MAIN_MENU_ITEMS): # Check settings changes in show menu show_menu_new_setting = bool( g.ADDON.getSettingBool('_'.join(('show_menu', menu_id)))) show_menu_old_setting = g.LOCAL_DB.get_value( 'menu_{}_show'.format(menu_id), True, TABLE_SETTINGS_MONITOR) if show_menu_new_setting != show_menu_old_setting: g.LOCAL_DB.set_value('menu_{}_show'.format(menu_id), show_menu_new_setting, TABLE_SETTINGS_MONITOR) reboot_addon = True # Check settings changes in sort order of menu if menu_data.get('request_context_name'): menu_sortorder_new_setting = int( g.ADDON.getSettingInt('_'.join( ('menu_sortorder', menu_data['path'][1])))) menu_sortorder_old_setting = g.LOCAL_DB.get_value( 'menu_{}_sortorder'.format(menu_id), 0, TABLE_SETTINGS_MONITOR) if menu_sortorder_new_setting != menu_sortorder_old_setting: g.LOCAL_DB.set_value('menu_{}_sortorder'.format(menu_id), menu_sortorder_new_setting, TABLE_SETTINGS_MONITOR) # We remove the cache to allow get the new results in the chosen order clean_cache = True # Check changes on content profiles # This is necessary because it is possible that some manifests # could be cached using the previous settings (see msl_handler - load_manifest) menu_keys = [ 'enable_dolby_sound', 'enable_vp9_profiles', 'enable_hevc_profiles', 'enable_hdr_profiles', 'enable_dolbyvision_profiles', 'enable_force_hdcp', 'disable_webvtt_subtitle' ] collect_int = '' for menu_key in menu_keys: collect_int += unicode(int(g.ADDON.getSettingBool(menu_key))) collect_int_old = g.LOCAL_DB.get_value('content_profiles_int', '', TABLE_SETTINGS_MONITOR) if collect_int != collect_int_old: g.LOCAL_DB.set_value('content_profiles_int', collect_int, TABLE_SETTINGS_MONITOR) clean_cache = True # Avoid perform these operations when the add-on is installed from scratch and there are no credentials if (clean_cache or reboot_addon) and not common.check_credentials(): clean_cache = False reboot_addon = False if clean_cache: common.run_plugin( 'plugin://plugin.video.netflix/action/purge_cache/' '?on_disk=True&no_notification=True') if reboot_addon: common.debug('SettingsMonitor: addon will be rebooted') url = 'plugin://plugin.video.netflix/directory/root' # Open root page xbmc.executebuiltin( 'Container.Update({})'.format(url)) # replace=reset history
def _on_change(self): common.debug( 'SettingsMonitor: Settings changed, reinitialize global settings') g.init_globals(sys.argv)
def _on_change(self): common.debug( 'SettingsMonitor: settings have been changed, started checks') reboot_addon = False use_mysql = g.ADDON.getSettingBool('use_mysql') use_mysql_old = g.LOCAL_DB.get_value('use_mysql', False, TABLE_SETTINGS_MONITOR) use_mysql_turned_on = use_mysql and not use_mysql_old common.debug('SettingsMonitor: Reinitialization of global settings') g.init_globals(sys.argv, reboot_addon) # Check the MySQL connection status after reinitialization of global settings use_mysql_after = g.ADDON.getSettingBool('use_mysql') if use_mysql_turned_on and use_mysql_after: g.LOCAL_DB.set_value('use_mysql', True, TABLE_SETTINGS_MONITOR) ui.show_notification(g.ADDON.getLocalizedString(30202)) if not use_mysql_after and use_mysql_old: g.LOCAL_DB.set_value('use_mysql', False, TABLE_SETTINGS_MONITOR) # Check if the custom esn is changed custom_esn = g.ADDON.getSetting('esn') custom_esn_old = g.LOCAL_DB.get_value('custom_esn', '', TABLE_SETTINGS_MONITOR) if custom_esn != custom_esn_old: g.LOCAL_DB.set_value('custom_esn', custom_esn, TABLE_SETTINGS_MONITOR) common.send_signal(signal=common.Signals.ESN_CHANGED, data=g.get_esn()) # Check menu settings changes sort_order_type_changed = False for menu_id, menu_data in g.MAIN_MENU_ITEMS.iteritems(): # Check settings changes in show menu show_menu_new_setting = bool( g.ADDON.getSettingBool('_'.join(('show_menu', menu_id)))) show_menu_old_setting = g.LOCAL_DB.get_value( 'menu_{}_show'.format(menu_id), True, TABLE_SETTINGS_MONITOR) if show_menu_new_setting != show_menu_old_setting: g.LOCAL_DB.set_value('menu_{}_show'.format(menu_id), show_menu_new_setting, TABLE_SETTINGS_MONITOR) reboot_addon = True # Check settings changes in sort order of menu if menu_data.get('request_context_name'): menu_sortorder_new_setting = int( g.ADDON.getSettingInt('_'.join( ('menu_sortorder', menu_data['path'][1])))) menu_sortorder_old_setting = g.LOCAL_DB.get_value( 'menu_{}_sortorder'.format(menu_id), 0, TABLE_SETTINGS_MONITOR) if menu_sortorder_new_setting != menu_sortorder_old_setting: g.LOCAL_DB.set_value('menu_{}_sortorder'.format(menu_id), menu_sortorder_new_setting, TABLE_SETTINGS_MONITOR) sort_order_type_changed = True if sort_order_type_changed: # We remove the cache to allow get the new results in the chosen order common.run_plugin( 'plugin://plugin.video.netflix/action/purge_cache/' '?on_disk=True&no_notification=True') if reboot_addon: common.debug('SettingsMonitor: addon will be rebooted') url = 'plugin://plugin.video.netflix/directory/root' xbmc.executebuiltin( 'XBMC.Container.Update(path,replace)') # Clean path history xbmc.executebuiltin( 'Container.Update({})'.format(url)) # Open root page