4
4
5
5
from __future__ import absolute_import , division , unicode_literals
6
6
import os
7
+ import json
7
8
8
9
from . import config
9
10
from .kodiutils import (addon_version , browsesingle , delete , exists , get_proxies , get_setting , get_setting_bool , get_setting_float , get_setting_int , jsonrpc ,
10
11
kodi_to_ascii , kodi_version , listdir , localize , log , notification , ok_dialog , progress_dialog , select_dialog ,
11
12
set_setting , set_setting_bool , textviewer , translate_path , yesno_dialog )
12
13
from .utils import arch , download_path , http_download , parse_version , remove_tree , store , system_os , temp_path , unzip , userspace64
13
- from .widevine .arm import dl_extract_widevine , extract_widevine , install_widevine_arm
14
- from .widevine .widevine import (backup_path , cdm_from_repo , choose_widevine_from_repo , has_widevinecdm , ia_cdm_path , install_cdm_from_backup , latest_widevine_available_from_repo ,
15
- latest_widevine_version , load_widevine_config , missing_widevine_libs , widevines_available_from_repo , widevine_config_path , widevine_eula , widevinecdm_path )
14
+ from .widevine .arm import dl_extract_widevine_chromeos , extract_widevine_chromeos , install_widevine_arm
15
+ from .widevine .arm_lacros import cdm_from_lacros , latest_lacros
16
+ from .widevine .widevine import (backup_path , has_widevinecdm , ia_cdm_path ,
17
+ install_cdm_from_backup , latest_widevine_version ,
18
+ load_widevine_config , missing_widevine_libs , widevine_config_path ,
19
+ widevine_eula , widevinecdm_path )
20
+ from .widevine .repo import cdm_from_repo , choose_widevine_from_repo , latest_widevine_available_from_repo
16
21
from .unicodes import compat_path
17
22
18
23
# NOTE: Work around issue caused by platform still using os.popen()
@@ -179,6 +184,10 @@ def _install_widevine_from_repo(bpath, choose_version=False):
179
184
cdm = choose_widevine_from_repo ()
180
185
else :
181
186
cdm = latest_widevine_available_from_repo ()
187
+
188
+ if not cdm :
189
+ return cdm
190
+
182
191
cdm_version = cdm .get ('version' )
183
192
184
193
if not exists (download_path (cdm .get ('url' ))):
@@ -243,7 +252,7 @@ def install_widevine(self, choose_version=False):
243
252
def install_widevine_from (self ):
244
253
"""Install Widevine from a given URL or file."""
245
254
if yesno_dialog (None , localize (30066 )): # download resource with widevine from url? no means specify local
246
- result = dl_extract_widevine (get_setting ("image_url" ), backup_path ())
255
+ result = dl_extract_widevine_chromeos (get_setting ("image_url" ), backup_path ())
247
256
if not result :
248
257
return result
249
258
@@ -256,7 +265,7 @@ def install_widevine_from(self):
256
265
return False
257
266
258
267
image_version = os .path .basename (image_path ).split ("_" )[1 ]
259
- progress = extract_widevine (backup_path (), image_path , image_version )
268
+ progress = extract_widevine_chromeos (backup_path (), image_path , image_version )
260
269
if not progress :
261
270
return False
262
271
@@ -293,6 +302,29 @@ def _first_run():
293
302
return True
294
303
return False
295
304
305
+ @staticmethod
306
+ def get_current_wv ():
307
+ """Returns which component is used (widevine/chromeos/lacros) and the current version"""
308
+ wv_config = load_widevine_config ()
309
+ component = 'Widevine CDM'
310
+ current_version = '0'
311
+
312
+ if not wv_config :
313
+ log (3 , 'Widevine config missing. Could not determine current version, forcing update.' )
314
+ elif cdm_from_repo ():
315
+ current_version = wv_config ['version' ]
316
+ elif cdm_from_lacros ():
317
+ component = 'Lacros image'
318
+ try :
319
+ current_version = wv_config ['img_version' ] # if lib was installed from chromeos image, there is no img_version
320
+ except KeyError :
321
+ pass
322
+ else :
323
+ component = 'Chrome OS'
324
+ current_version = wv_config ['version' ]
325
+
326
+ return component , current_version
327
+
296
328
def _update_widevine (self ):
297
329
"""Prompts user to upgrade Widevine CDM when a newer version is available."""
298
330
from time import localtime , strftime , time
@@ -308,21 +340,9 @@ def _update_widevine(self):
308
340
log (2 , 'Widevine update check was made on {date}' , date = strftime ('%Y-%m-%d %H:%M' , localtime (last_check )))
309
341
return
310
342
311
- wv_config = load_widevine_config ()
312
- if not wv_config :
313
- log (3 , 'Widevine config missing. Could not determine current version, forcing update.' )
314
- current_version = '0'
315
- elif cdm_from_repo ():
316
- component = 'Widevine CDM'
317
- current_version = wv_config ['version' ]
318
- latest_version = latest_widevine_available_from_repo ().get ('version' )
319
- else :
320
- component = 'Chrome OS'
321
- current_version = wv_config ['version' ]
322
- latest_version = latest_widevine_version ()
323
- if not latest_version :
324
- log (3 , 'Updating Widevine CDM failed. Could not determine latest version.' )
325
- return
343
+ component , current_version = self .get_current_wv ()
344
+
345
+ latest_version = latest_widevine_version ()
326
346
327
347
log (0 , 'Latest {component} version is {version}' , component = component , version = latest_version )
328
348
log (0 , 'Current {component} version installed is {version}' , component = component , version = current_version )
@@ -459,9 +479,11 @@ def info_dialog(self):
459
479
else :
460
480
wv_updated = 'Never'
461
481
text += localize (30821 , version = self ._get_lib_version (widevinecdm_path ()), date = wv_updated ) + '\n '
462
- if arch () == 'arm' or arch () == 'arm64' and system_os () != 'Darwin' : # Chrome OS version
482
+ if not cdm_from_repo ():
463
483
wv_cfg = load_widevine_config ()
464
- if wv_cfg :
484
+ if wv_cfg and cdm_from_lacros (): # Lacros image version
485
+ text += localize (30825 , image = "Lacros" , version = wv_cfg ['img_version' ]) + '\n '
486
+ elif wv_cfg : # Chrome OS version
465
487
text += localize (30822 , name = wv_cfg ['hwidmatch' ].split ()[0 ].lstrip ('^' ), version = wv_cfg ['version' ]) + '\n '
466
488
if get_setting_float ('last_check' , 0.0 ):
467
489
wv_check = strftime ('%Y-%m-%d %H:%M' , localtime (get_setting_float ('last_check' , 0.0 )))
@@ -487,7 +509,11 @@ def rollback_libwv(self):
487
509
notification (localize (30004 ), localize (30041 ))
488
510
return
489
511
490
- installed_version = load_widevine_config ()['version' ]
512
+ try :
513
+ installed_version = load_widevine_config ()['img_version' ]
514
+ except KeyError :
515
+ installed_version = load_widevine_config ()['version' ]
516
+
491
517
del versions [versions .index (installed_version )]
492
518
493
519
if cdm_from_repo ():
0 commit comments