1111 set_setting , set_setting_bool , textviewer , translate_path , yesno_dialog )
1212from .utils import arch , http_download , remove_tree , run_cmd , store , system_os , temp_path , unzip
1313from .widevine .arm import install_widevine_arm , unmount
14- from .widevine .widevine import (backup_path , has_widevinecdm , ia_cdm_path , install_cdm_from_backup , latest_widevine_version ,
14+ from .widevine .widevine import (backup_path , has_widevinecdm , get_lib_version , ia_cdm_path , install_cdm_from_backup , latest_widevine_version ,
1515 load_widevine_config , missing_widevine_libs , widevine_config_path , widevine_eula , widevinecdm_path )
1616from .unicodes import compat_path
1717
@@ -96,18 +96,6 @@ def _inputstream_version(self):
9696 from .unicodes import to_unicode
9797 return to_unicode (addon .getAddonInfo ('version' ))
9898
99- @staticmethod
100- def _get_lib_version (path ):
101- if not path or not exists (path ):
102- return '(Not found)'
103- import re
104- with open (compat_path (path ), 'rb' ) as library :
105- match = re .search (br'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' , library .read ())
106- if not match :
107- return '(Undetected)'
108- from .unicodes import to_unicode
109- return to_unicode (match .group (0 ))
110-
11199 def _has_inputstream (self ):
112100 """Checks if selected InputStream add-on is installed."""
113101 data = jsonrpc (method = 'Addons.GetAddonDetails' , params = dict (addonid = self .inputstream_addon ))
@@ -195,7 +183,9 @@ def install_and_finish(self, progress, version):
195183 """Installs the cdm from backup and runs checks"""
196184
197185 progress .update (97 , message = localize (30049 )) # Installing Widevine CDM
198- install_cdm_from_backup (version )
186+ if not install_cdm_from_backup (version ):
187+ progress .close ()
188+ return False
199189
200190 progress .update (98 , message = localize (30050 )) # Finishing
201191 if has_widevinecdm ():
@@ -432,7 +422,7 @@ def info_dialog(self):
432422 wv_updated = strftime ('%Y-%m-%d %H:%M' , localtime (get_setting_float ('last_modified' , 0.0 )))
433423 else :
434424 wv_updated = 'Never'
435- text += localize (30821 , version = self . _get_lib_version (widevinecdm_path ()), date = wv_updated ) + '\n '
425+ text += localize (30821 , version = get_lib_version (widevinecdm_path ()), date = wv_updated ) + '\n '
436426 if arch () in ('arm' , 'arm64' ): # Chrome OS version
437427 wv_cfg = load_widevine_config ()
438428 if wv_cfg :
@@ -451,7 +441,8 @@ def info_dialog(self):
451441 log (2 , '\n {info}' .format (info = kodi_to_ascii (text )))
452442 textviewer (localize (30901 ), text )
453443
454- def rollback_libwv (self ):
444+ @staticmethod
445+ def rollback_libwv ():
455446 """Rollback lib to a version specified by the user"""
456447 bpath = backup_path ()
457448 versions = listdir (bpath )
@@ -470,7 +461,7 @@ def rollback_libwv(self):
470461 show_versions = []
471462
472463 for version in versions :
473- lib_version = self . _get_lib_version (os .path .join (bpath , version , config .WIDEVINE_CDM_FILENAME [system_os ()]))
464+ lib_version = get_lib_version (os .path .join (bpath , version , config .WIDEVINE_CDM_FILENAME [system_os ()]))
474465 show_versions .append ('{} ({})' .format (lib_version , version ))
475466
476467 if not show_versions :
@@ -480,7 +471,7 @@ def rollback_libwv(self):
480471 version = select_dialog (localize (30057 ), show_versions )
481472 if version != - 1 :
482473 log (0 , 'Rollback to version {version}' , version = versions [version ])
483- install_cdm_from_backup (versions [version ])
484- notification (localize (30037 ), localize (30051 )) # Success! Widevine successfully installed.
474+ if install_cdm_from_backup (versions [version ]):
475+ notification (localize (30037 ), localize (30051 )) # Success! Widevine successfully installed.
485476
486477 return
0 commit comments