Exemplo n.º 1
0
 def autoselect_profile_remove(self, pathitems):  # pylint: disable=unused-argument
     """Remove the auto-selection set"""
     g.LOCAL_DB.set_value('autoselect_profile_guid', '')
     g.settings_monitor_suspend(True)
     g.ADDON.setSetting('autoselect_profile_name', '')
     g.ADDON.setSettingBool('autoselect_profile_enabled', False)
     g.settings_monitor_suspend(False)
Exemplo n.º 2
0
    def logout(self, url):
        """Logout of the current account and reset the session"""
        common.debug('Logging out of current account')

        g.settings_monitor_suspend(True)

        # Disable and reset auto-update / auto-sync features
        g.ADDON.setSettingInt('lib_auto_upd_mode', 0)
        g.ADDON.setSettingBool('lib_sync_mylist', False)
        g.SHARED_DB.delete_key('sync_mylist_profile_guid')

        # Disable and reset the auto-select profile
        g.LOCAL_DB.set_value('autoselect_profile_guid', '')
        g.ADDON.setSetting('autoselect_profile_name', '')
        g.ADDON.setSettingBool('autoselect_profile_enabled', False)

        g.settings_monitor_suspend(False)

        # Delete cookie and credentials
        cookies.delete(self.account_hash)
        self._get('logout')
        common.purge_credentials()

        common.info('Logout successful')
        ui.show_notification(common.get_local_string(30113))
        self._init_session()
        xbmc.executebuiltin('Container.Update(path,replace)'
                            )  # Go to a fake page to clear screen
        # Open root page
        xbmc.executebuiltin('Container.Update({},replace)'.format(
            url))  # replace=reset history
Exemplo n.º 3
0
def _delete_non_existing_profiles(current_guids):
    list_guid = g.LOCAL_DB.get_guid_profiles()
    for guid in list_guid:
        if guid not in current_guids:
            common.debug('Deleting non-existing profile {}', guid)
            g.LOCAL_DB.delete_profile(guid)
            g.SHARED_DB.delete_profile(guid)
    # Ensures at least one active profile
    try:
        g.LOCAL_DB.get_active_profile_guid()
    except ProfilesMissing:
        g.LOCAL_DB.switch_active_profile(g.LOCAL_DB.get_guid_owner_profile())
    g.settings_monitor_suspend(True)
    # Verify if auto select profile exists
    autoselect_profile_guid = g.LOCAL_DB.get_value('autoselect_profile_guid',
                                                   '')
    if autoselect_profile_guid and autoselect_profile_guid not in current_guids:
        common.warn('Auto-selection disabled, the GUID {} not more exists',
                    autoselect_profile_guid)
        g.LOCAL_DB.set_value('autoselect_profile_guid', '')
        g.ADDON.setSetting('autoselect_profile_name', '')
        g.ADDON.setSettingBool('autoselect_profile_enabled', False)
    # Verify if profile for library playback exists
    library_playback_profile_guid = g.LOCAL_DB.get_value(
        'library_playback_profile_guid')
    if library_playback_profile_guid and library_playback_profile_guid not in current_guids:
        common.warn(
            'Profile set for playback from library cleared, the GUID {} not more exists',
            library_playback_profile_guid)
        # Save the selected profile guid
        g.LOCAL_DB.set_value('library_playback_profile_guid', '')
        # Save the selected profile name
        g.ADDON.setSetting('library_playback_profile', '')
    g.settings_monitor_suspend(False)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
 def _home_autoselect_profile(self):
     """
     Show home listing if profile auto-selection is enabled
     :return: True when the auto-selection is done correctly
     """
     autoselect_profile_guid = g.LOCAL_DB.get_value(
         'autoselect_profile_guid', '')
     if autoselect_profile_guid:
         # Check if the GUID still exists in the profile list
         if autoselect_profile_guid not in g.LOCAL_DB.get_guid_profiles():
             common.warn(
                 'Auto-selection of profile not performed, the GUID {} not exist',
                 autoselect_profile_guid)
             g.LOCAL_DB.set_value('autoselect_profile_guid', '')
             g.settings_monitor_suspend(True)
             g.ADDON.setSetting('autoselect_profile_name', '')
             g.ADDON.setSettingBool('autoselect_profile_enabled', False)
             g.settings_monitor_suspend(False)
         else:
             common.info('Performing auto-selection of profile {}',
                         autoselect_profile_guid)
             api.activate_profile(autoselect_profile_guid)
             self.home(None, False)
             return True
     return False
Exemplo n.º 6
0
def run_addon_configuration(show_end_msg=False):
    """
    Add-on configuration wizard,
    automatically configures profiles and add-ons dependencies, based on user-supplied data and device characteristics
    """
    system = get_system_platform()
    debug('Running add-on configuration wizard ({})', system)
    g.settings_monitor_suspend(True, False)
    is_4k_capable = is_device_4k_capable()

    _set_profiles(system, is_4k_capable)
    _set_kodi_settings(system)
    _set_isa_addon_settings(is_4k_capable, system == 'android')

    # This settings for now used only with android devices and it should remain disabled (keep it for test),
    # in the future it may be useful for other platforms or it may be removed
    g.ADDON.setSettingBool('enable_force_hdcp', False)

    # Enable UpNext if it is installed and enabled
    g.ADDON.setSettingBool(
        'UpNextNotifier_enabled',
        getCondVisibility('System.AddonIsEnabled(service.upnext)'))

    g.settings_monitor_suspend(False)
    if show_end_msg:
        show_ok_dialog(get_local_string(30154), get_local_string(30157))
Exemplo n.º 7
0
 def autoselect_profile_set(self, pathitems):  # pylint: disable=unused-argument
     """Save the GUID for profile auto-selection"""
     g.LOCAL_DB.set_value('autoselect_profile_guid', self.params['profile_guid'])
     g.settings_monitor_suspend(True)
     g.ADDON.setSetting('autoselect_profile_name', self.params['profile_name'])
     g.ADDON.setSettingBool('autoselect_profile_enabled', True)
     g.settings_monitor_suspend(False)
     ui.show_notification(common.get_local_string(30058).format(self.params['profile_name']))
 def onSettingsChanged(self):
     status = g.settings_monitor_suspend_status()
     if status == 'First':
         common.warn('SettingsMonitor: triggered but in suspend status (at first change)')
         g.settings_monitor_suspend(False)
         return
     if status == 'True':
         common.warn('SettingsMonitor: triggered but in suspend status (permanent)')
         return
     self._on_change()
Exemplo n.º 9
0
 def save_autologin(self, pathitems):
     """Save autologin data"""
     try:
         g.settings_monitor_suspend(True)
         g.ADDON.setSetting('autologin_user', self.params['autologin_user'])
         g.ADDON.setSetting('autologin_id', pathitems[1])
         g.ADDON.setSetting('autologin_enable', 'true')
         g.settings_monitor_suspend(False)
     except (KeyError, IndexError):
         common.error('Cannot save autologin - invalid params')
     g.CACHE.invalidate()
     common.refresh_container()
    def logout(self, url):
        """Logout of the current account and reset the session"""
        common.debug('Logging out of current account')

        # Perform the website logout
        self._get('logout')

        g.settings_monitor_suspend(True)

        # Disable and reset auto-update / auto-sync features
        g.ADDON.setSettingInt('lib_auto_upd_mode', 1)
        g.ADDON.setSettingBool('lib_sync_mylist', False)
        g.SHARED_DB.delete_key('sync_mylist_profile_guid')

        # Disable and reset the auto-select profile
        g.LOCAL_DB.set_value('autoselect_profile_guid', '')
        g.ADDON.setSetting('autoselect_profile_name', '')
        g.ADDON.setSettingBool('autoselect_profile_enabled', False)

        # Reset of selected profile guid for library playback
        g.LOCAL_DB.set_value('library_playback_profile_guid', '')
        g.ADDON.setSetting('library_playback_profile', '')

        g.settings_monitor_suspend(False)

        # Delete cookie and credentials
        self.session.cookies.clear()
        cookies.delete(self.account_hash)
        common.purge_credentials()

        # Reset the ESN obtained from website/generated
        g.LOCAL_DB.set_value('esn', '', TABLE_SESSION)

        # Reinitialize the MSL handler (delete msl data file, then reset everything)
        common.send_signal(signal=common.Signals.REINITIALIZE_MSL_HANDLER,
                           data=True)

        g.CACHE.clear(clear_database=True)

        common.info('Logout successful')
        ui.show_notification(common.get_local_string(30113))
        self._init_session()
        xbmc.executebuiltin('Container.Update(path,replace)'
                            )  # Go to a fake page to clear screen
        # Open root page
        xbmc.executebuiltin('Container.Update({},replace)'.format(
            url))  # replace=reset history
Exemplo n.º 11
0
 def reset_esn(self, pathitems=None):  # pylint: disable=unused-argument
     """Reset the ESN stored (retrieved from website and manual)"""
     from resources.lib.database.db_utils import (TABLE_SESSION, TABLE_SETTINGS_MONITOR)
     if not ui.ask_for_confirmation(common.get_local_string(30217),
                                    common.get_local_string(30218)):
         return
     # Reset the ESN obtained from website/generated
     g.LOCAL_DB.set_value('esn', '', TABLE_SESSION)
     # Reset the custom ESN (manual ESN from settings)
     g.settings_monitor_suspend(at_first_change=True)
     g.ADDON.setSetting('esn', '')
     # Reset the custom ESN (backup of manual ESN from settings, used in settings_monitor.py)
     g.LOCAL_DB.set_value('custom_esn', '', TABLE_SETTINGS_MONITOR)
     # Perform a new login to get/generate a new ESN
     api.login(ask_credentials=False)
     # Warning after login netflix switch to the main profile! so return to the main screen
     # Open root page
     common.container_update(g.BASE_URL, True)
Exemplo n.º 12
0
 def reset_esn(self, pathitems=None):  # pylint: disable=unused-argument
     """Reset the ESN stored (retrieved from website and manual)"""
     from resources.lib.database.db_utils import (TABLE_SESSION,
                                                  TABLE_SETTINGS_MONITOR)
     if not ui.ask_for_confirmation(common.get_local_string(30217),
                                    common.get_local_string(30218)):
         return
     # Reset the ESN obtained from website/generated
     g.LOCAL_DB.set_value('esn', '', TABLE_SESSION)
     # Reset the custom ESN (manual ESN from settings)
     g.settings_monitor_suspend(at_first_change=True)
     g.ADDON.setSetting('esn', '')
     # Reset the custom ESN (backup of manual ESN from settings, used in settings_monitor.py)
     g.LOCAL_DB.set_value('custom_esn', '', TABLE_SETTINGS_MONITOR)
     # Perform a new login to get/generate a new ESN
     api.login(ask_credentials=False)
     # Warning after login netflix switch to the main profile! so return to the main screen
     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