11
11
set_setting , set_setting_bool , textviewer , translate_path , yesno_dialog )
12
12
from .utils import arch , http_download , remove_tree , run_cmd , store , system_os , temp_path , unzip
13
13
from .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 ,
15
15
load_widevine_config , missing_widevine_libs , widevine_config_path , widevine_eula , widevinecdm_path )
16
16
from .unicodes import compat_path
17
17
@@ -96,18 +96,6 @@ def _inputstream_version(self):
96
96
from .unicodes import to_unicode
97
97
return to_unicode (addon .getAddonInfo ('version' ))
98
98
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
-
111
99
def _has_inputstream (self ):
112
100
"""Checks if selected InputStream add-on is installed."""
113
101
data = jsonrpc (method = 'Addons.GetAddonDetails' , params = dict (addonid = self .inputstream_addon ))
@@ -195,7 +183,9 @@ def install_and_finish(self, progress, version):
195
183
"""Installs the cdm from backup and runs checks"""
196
184
197
185
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
199
189
200
190
progress .update (98 , message = localize (30050 )) # Finishing
201
191
if has_widevinecdm ():
@@ -432,7 +422,7 @@ def info_dialog(self):
432
422
wv_updated = strftime ('%Y-%m-%d %H:%M' , localtime (get_setting_float ('last_modified' , 0.0 )))
433
423
else :
434
424
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 '
436
426
if arch () in ('arm' , 'arm64' ): # Chrome OS version
437
427
wv_cfg = load_widevine_config ()
438
428
if wv_cfg :
@@ -451,7 +441,8 @@ def info_dialog(self):
451
441
log (2 , '\n {info}' .format (info = kodi_to_ascii (text )))
452
442
textviewer (localize (30901 ), text )
453
443
454
- def rollback_libwv (self ):
444
+ @staticmethod
445
+ def rollback_libwv ():
455
446
"""Rollback lib to a version specified by the user"""
456
447
bpath = backup_path ()
457
448
versions = listdir (bpath )
@@ -470,7 +461,7 @@ def rollback_libwv(self):
470
461
show_versions = []
471
462
472
463
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 ()]))
474
465
show_versions .append ('{} ({})' .format (lib_version , version ))
475
466
476
467
if not show_versions :
@@ -480,7 +471,7 @@ def rollback_libwv(self):
480
471
version = select_dialog (localize (30057 ), show_versions )
481
472
if version != - 1 :
482
473
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.
485
476
486
477
return
0 commit comments