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 _sync_library(videoid, operation):
    operation = {
        'add': 'export_silent',
        'remove': 'remove_silent'}.get(operation)
    if operation and g.ADDON.getSettingBool('lib_sync_mylist'):
        sync_mylist_profile_guid = g.SHARED_DB.get_value('sync_mylist_profile_guid',
                                                         g.LOCAL_DB.get_guid_owner_profile())
        # Allow to sync library with My List only by chosen profile
        if sync_mylist_profile_guid != g.LOCAL_DB.get_active_profile_guid():
            return
        common.debug('Syncing library due to change of my list')
        # xbmc.executebuiltin is running with Block, to prevent update the list before op. is done
        common.run_plugin(common.build_url([operation], videoid, mode=g.MODE_LIBRARY), block=True)
    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))
Beispiel #4
0
    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
Beispiel #5
0
    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