def _reset(self): if not ui.ask_for_confirmation( common.get_local_string(13007), # 13007=Reset common.get_local_string(30609)): return with common.show_busy_dialog(): # Set WV Sec. Lev. to Disabled self._ensure_wv_btn_check( self.WV_SECLEV_MAP_BTN[WidevineForceSecLev.DISABLED]) self.wv_sec_lev_new = WidevineForceSecLev.DISABLED if self.is_android: # Generate the ESN self.esn_new = generate_android_esn( wv_force_sec_lev=self.wv_sec_lev_new) else: # To retrieve the ESN from the website, # to avoid possible problems we refresh the nf session data to get a new ESN set_website_esn('') common.make_call('refresh_session_data', {'update_profiles': False}) self.esn_new = get_website_esn() if not self.esn_new: raise Exception( 'It was not possible to obtain the ESN, try restarting the add-on' ) self._update_esn_label()
def _get_new_esn(self): if common.get_system_platform() == 'android': return generate_android_esn() # In the all other systems, create a new ESN by using the existing ESN prefix current_esn = G.LOCAL_DB.get_value('esn', table=TABLE_SESSION) from re import search esn_prefix_match = search(r'.+-', current_esn) if not esn_prefix_match: raise Exception('It was not possible to generate a new ESN. Before try login.') return generate_esn(esn_prefix_match.group(0))
def _check_esn(): """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) if not custom_esn: # Check if "Force identification as L3 Widevine device" is changed (ANDROID ONLY) is_l3_forced = bool(G.ADDON.getSettingBool('force_widevine_l3')) is_l3_forced_old = G.LOCAL_DB.get_value('force_widevine_l3', False, TABLE_SETTINGS_MONITOR) if is_l3_forced != is_l3_forced_old: G.LOCAL_DB.set_value('force_widevine_l3', is_l3_forced, TABLE_SETTINGS_MONITOR) # If user has changed setting is needed clear previous ESN and perform a new handshake with the new one G.LOCAL_DB.set_value('esn', generate_android_esn() or '', TABLE_SESSION) common.send_signal(signal=common.Signals.ESN_CHANGED)
def _refresh_esn(self): """Refresh the ESN based on Widevine security level (ANDROID ONLY)""" # Refresh only is when there is no a full-length ESN if self.is_android and len(self.esn_new or self.esn) < 50: self.esn_new = generate_android_esn( wv_force_sec_lev=self.wv_sec_lev_new or self.wv_force_sec_lev)
def _save_system_info(): # Ask to save to a file filename = 'NFSystemInfo.txt' path = ui.show_browse_dialog( common.get_local_string(30603) + ' - ' + filename) if not path: return # This collect the main data to allow verification checks for problems data = 'Netflix add-on version: ' + G.VERSION data += '\nDebug logging level: ' + LOG.level data += '\nSystem platform: ' + common.get_system_platform() data += '\nMachine architecture: ' + common.get_machine() data += '\nUser agent string: ' + common.get_user_agent() data += '\n\n' + '#### Widevine info ####\n' if common.get_system_platform() == 'android': data += '\nSystem ID: ' + G.LOCAL_DB.get_value( 'drm_system_id', '--not obtained--', TABLE_SESSION) data += '\nSecurity level: ' + G.LOCAL_DB.get_value( 'drm_security_level', '--not obtained--', TABLE_SESSION) data += '\nHDCP level: ' + G.LOCAL_DB.get_value( 'drm_hdcp_level', '--not obtained--', TABLE_SESSION) wv_force_sec_lev = G.LOCAL_DB.get_value('widevine_force_seclev', WidevineForceSecLev.DISABLED, TABLE_SESSION) data += '\nForced security level setting is: ' + wv_force_sec_lev else: try: from ctypes import (CDLL, c_char_p) cdm_lib_file_path = _get_cdm_file_path() try: lib = CDLL(cdm_lib_file_path) data += '\nLibrary status: Correctly loaded' try: lib.GetCdmVersion.restype = c_char_p data += '\nVersion: ' + lib.GetCdmVersion().decode('utf-8') except Exception: # pylint: disable=broad-except # This can happen if the endpoint 'GetCdmVersion' is changed data += '\nVersion: Reading error' except Exception as exc: # pylint: disable=broad-except # This should not happen but currently InputStream Helper does not perform any verification checks on # downloaded and installed files, so if due to an problem it installs a CDM for a different architecture # or the files are corrupted, the user can no longer play videos and does not know what to do data += '\nLibrary status: Error loading failed' data += '\n>>> It is possible that is installed a CDM of a wrong architecture or is corrupted' data += '\n>>> Suggested solutions:' data += '\n>>> - Restore a previous version of Widevine library from InputStream Helper add-on settings' data += '\n>>> - Report the problem to the GitHub of InputStream Helper add-on' data += '\n>>> Error details: {}'.format(exc) except Exception as exc: # pylint: disable=broad-except data += '\nThe data could not be obtained. Error details: {}'.format( exc) data += '\n\n' + '#### ESN ####\n' esn = get_esn() or '--not obtained--' data += '\nUsed ESN: ' + common.censure(esn) if len(esn) > 50 else esn data += '\nWebsite ESN: ' + (get_website_esn() or '--not obtained--') data += '\nAndroid generated ESN: ' + (generate_android_esn() or '--not obtained--') if common.get_system_platform() == 'android': data += '\n\n' + '#### Device system info ####\n' try: import subprocess info = subprocess.check_output(['/system/bin/getprop' ]).decode('utf-8') data += '\n' + info except Exception as exc: # pylint: disable=broad-except data += '\nThe data could not be obtained. Error: {}'.format(exc) data += '\n' try: common.save_file(common.join_folders_paths(path, filename), data.encode('utf-8')) ui.show_notification('{}: {}'.format(xbmc.getLocalizedString(35259), filename)) # 35259=Saved except Exception as exc: # pylint: disable=broad-except LOG.error('save_file error: {}', exc) ui.show_notification('Error! Try another path')