Exemplo n.º 1
0
def _perform_service_changes(previous_ver, current_ver):
    """Perform actions for an version bump"""
    LOG.debug('Initialize service upgrade operations, from version {} to {})',
              previous_ver, current_ver)
    # Clear cache (prevents problems when netflix change data structures)
    G.CACHE.clear()
    if previous_ver and is_less_version(previous_ver, '1.9.0'):
        # In the version 1.9.0 has been changed the COOKIE_ filename with a static filename
        from resources.lib.upgrade_actions import rename_cookie_file
        rename_cookie_file()
    if previous_ver and is_less_version(previous_ver, '1.12.0'):
        # In the version 1.13.0:
        # - 'force_widevine' on setting.xml has been moved
        #   as 'widevine_force_seclev' in TABLE_SESSION with different values:
        force_widevine = G.ADDON.getSettingString('force_widevine')
        # Old values: Disabled|Widevine L3|Widevine L3 (ID-4445)
        # New values: Disabled|L3|L3 (ID 4445)
        if force_widevine == 'Widevine L3':
            G.LOCAL_DB.set_value('widevine_force_seclev',
                                 'L3',
                                 table=TABLE_SESSION)
        elif force_widevine == 'Widevine L3 (ID-4445)':
            G.LOCAL_DB.set_value('widevine_force_seclev',
                                 'L3 (ID 4445)',
                                 table=TABLE_SESSION)
        # - 'esn' on setting.xml is not more used but if was set the value need to be copied on 'esn' on TABLE_SESSION:
        esn = G.ADDON.getSettingString('esn')
        if esn:
            from resources.lib.utils.esn import set_esn
            set_esn(esn)
        # - 'suspend_settings_monitor' is not more used
        G.LOCAL_DB.delete_key('suspend_settings_monitor')
    # Always leave this to last - After the operations set current version
    G.LOCAL_DB.set_value('service_previous_version', current_ver)
Exemplo n.º 2
0
 def _revert_changes(self):
     if self.changes_applied:
         # Revert the saved changes
         # The changes to MSL (key handshake) will be done when will be played a video
         set_esn(self.esn)
         G.LOCAL_DB.set_value('widevine_force_seclev',
                              self.wv_force_sec_lev, TABLE_SESSION)
         # Delete manifests cache, to prevent possible problems in relation to previous ESN used
         from resources.lib.common.cache_utils import CACHE_MANIFESTS
         G.CACHE.clear([CACHE_MANIFESTS])
Exemplo n.º 3
0
 def _apply_changes(self):
     with common.show_busy_dialog():
         set_esn(self.esn_new or self.esn)
         G.LOCAL_DB.set_value('widevine_force_seclev', self.wv_sec_lev_new
                              or self.wv_force_sec_lev, TABLE_SESSION)
         # Try apply the changes by performing the MSL key handshake right now
         try:
             common.make_call('perform_key_handshake',
                              endpoint=IPC_ENDPOINT_MSL)
             # When the MSL not raise errors not always means that the device can play the videos
             # because the MSL manifest/license request may not be granted (you have to play a video to know it).
             ui.show_ok_dialog(common.get_local_string(30600),
                               common.get_local_string(30606))
         except Exception as exc:  # pylint: disable=broad-except
             ui.show_ok_dialog(common.get_local_string(30600),
                               common.get_local_string(30607).format(exc))
     self.changes_applied = True
def _perform_service_changes(previous_ver, current_ver):
    """Perform actions for an version bump"""
    LOG.debug('Initialize service upgrade operations, from version {} to {})', previous_ver, current_ver)
    # Clear cache (prevents problems when netflix change data structures)
    G.CACHE.clear()
    if previous_ver and is_less_version(previous_ver, '1.2.0'):
        # In the version 1.2.0 has been implemented a new cache management
        from resources.lib.upgrade_actions import delete_cache_folder
        delete_cache_folder()
        # In the version 1.2.0 has been implemented in auto-update mode setting the option to disable the feature
        try:
            lib_auto_upd_mode = G.ADDON.getSettingInt('lib_auto_upd_mode')
            with G.SETTINGS_MONITOR.ignore_events(1):
                G.ADDON.setSettingInt('lib_auto_upd_mode', lib_auto_upd_mode + 1)
        except TypeError:
            # In case of a previous rollback this could fails
            with G.SETTINGS_MONITOR.ignore_events(1):
                G.ADDON.setSettingInt('lib_auto_upd_mode', 1)
    if previous_ver and is_less_version(previous_ver, '1.9.0'):
        # In the version 1.9.0 has been changed the COOKIE_ filename with a static filename
        from resources.lib.upgrade_actions import rename_cookie_file
        rename_cookie_file()
    if previous_ver and is_less_version(previous_ver, '1.12.0'):
        # In the version 1.13.0:
        # - 'force_widevine' on setting.xml has been moved
        #   as 'widevine_force_seclev' in TABLE_SESSION with different values:
        force_widevine = G.ADDON.getSettingString('force_widevine')
        # Old values: Disabled|Widevine L3|Widevine L3 (ID-4445)
        # New values: Disabled|L3|L3 (ID 4445)
        if force_widevine == 'Widevine L3':
            G.LOCAL_DB.set_value('widevine_force_seclev', 'L3', table=TABLE_SESSION)
        elif force_widevine == 'Widevine L3 (ID-4445)':
            G.LOCAL_DB.set_value('widevine_force_seclev', 'L3 (ID 4445)', table=TABLE_SESSION)
        # - 'esn' on setting.xml is not more used but if was set the value need to be copied on 'esn' on TABLE_SESSION:
        esn = G.ADDON.getSettingString('esn')
        if esn:
            from resources.lib.utils.esn import set_esn
            set_esn(esn)
        # - 'suspend_settings_monitor' is not more used
        G.LOCAL_DB.delete_key('suspend_settings_monitor')
    # Always leave this to last - After the operations set current version
    G.LOCAL_DB.set_value('service_previous_version', current_ver)
Exemplo n.º 5
0
 def onClick(self, controlId):
     # [Widevine sec. lev.] radio buttons - this setting can affect the ESN so make a preview of the change
     if controlId in self.WV_SECLEV_MAP_BTN.values():
         self._ensure_wv_btn_check(controlId)
         self.wv_sec_lev_new = list(self.WV_SECLEV_MAP_BTN.keys())[list(
             self.WV_SECLEV_MAP_BTN.values()).index(controlId)]
         self._refresh_esn()
         self._update_esn_label()
     # [Change ESN] button
     if controlId == 30010:
         self._change_esn()
     # [Reset] button - reset all settings to default
     if controlId == 30011:
         self._reset()
     # [Apply changes] button
     if controlId == 40020:
         self._apply_changes()
     # [OK] button - close and keep changes
     if controlId == 40021:
         if not self.changes_applied:
             # The changes to MSL (key handshake) will be done when will be played a video
             set_esn(self.esn_new or self.esn)
             G.LOCAL_DB.set_value(
                 'widevine_force_seclev', self.wv_sec_lev_new
                 or self.wv_force_sec_lev, TABLE_SESSION)
         # Delete manifests cache, to prevent possible problems in relation to previous ESN used
         from resources.lib.common.cache_utils import CACHE_MANIFESTS
         G.CACHE.clear([CACHE_MANIFESTS])
         self.close()
     # [X or Cancel] button - close and cancel changes
     if controlId in [40099, 40022]:
         self._revert_changes()
         self.close()
     # [Save system info] button
     if controlId == 30012:
         _save_system_info()
Exemplo n.º 6
0
    def get_manifest(self, viewable_id):
        """
        Get the manifests for the given viewable_id and returns a mpd-XML-Manifest

        :param viewable_id: The id of of the viewable
        :return: MPD XML Manifest or False if no success
        """
        try:
            esn = get_esn()
            # When the add-on is installed from scratch or you logout the account the ESN will be empty
            if not esn:
                esn = set_esn()
            manifest = self._get_manifest(viewable_id, esn)
        except MSLError as exc:
            if 'Email or password is incorrect' in str(exc):
                # Known cases when MSL error "Email or password is incorrect." can happen:
                # - If user change the password when the nf session was still active
                # - Netflix has reset the password for suspicious activity when the nf session was still active
                # Then clear the credentials and also user tokens.
                common.purge_credentials()
                self.msl_requests.crypto.clear_user_id_tokens()
            raise
        return self.__tranform_to_dash(manifest)