@@ -288,26 +288,22 @@ def _current_widevine_cdm_version(self):
288
288
return self ._http_request ()
289
289
290
290
def _parse_chromeos_recovery_conf (self ):
291
- """Parse the download URL and required disk space from the Chrome OS recovery configuration ."""
292
- download_dict = {}
291
+ """Parse the Chrome OS recovery configuration and put it in a dictionary ."""
292
+ devices = []
293
293
self ._url = config .CHROMEOS_RECOVERY_CONF
294
- conf = self ._http_request ().split ('\n \n ' )
295
- devices = [x for x in conf if 'name=' in x ]
296
- for device in devices :
297
- if config .CHROMEOS_ARM_HWID in device .split ('\n hwidmatch=' )[1 ].split ('\n ' )[0 ]:
298
- for line in device .splitlines ():
299
- if 'url' in line :
300
- download_dict ['url' ] = line .split ('url=' )[1 ]
301
- if 'zipfilesize' in line :
302
- zip_filesize = int (line .split ('filesize=' )[1 ])
303
- if 'zip' not in line and 'filesize' in line :
304
- bin_filesize = int (line .split ('filesize=' )[1 ])
305
-
306
- download_dict ['required_diskspace' ] = zip_filesize + bin_filesize
307
- return download_dict
308
-
309
- self ._log ('Failed to parse Chrome OS recovery.conf' )
310
- return False
294
+ conf = [x for x in self ._http_request ().split ('\n \n ' ) if 'name=' in x ]
295
+ for device in conf :
296
+ device_dict = {}
297
+ for device_info in device .splitlines ():
298
+ key_value = device_info .split ('=' )
299
+ key = key_value [0 ]
300
+ if len (key_value ) > 1 : # some keys have empty values
301
+ value = key_value [1 ]
302
+ device_dict [key ] = value
303
+ devices .append (device_dict )
304
+
305
+ self ._log ('chromeos devices: {0}' .format (devices ))
306
+ return devices
311
307
312
308
def _install_widevine_cdm_x86 (self ):
313
309
dialog = xbmcgui .Dialog ()
@@ -340,15 +336,16 @@ def _install_widevine_cdm_x86(self):
340
336
return False
341
337
342
338
def _install_widevine_cdm_arm (self ):
339
+ arm_device = [x for x in self ._parse_chromeos_recovery_conf () if config .CHROMEOS_ARM_HWID in x ['hwidmatch' ]][0 ]
340
+ required_diskspace = int (arm_device ['filesize' ]) + int (arm_device ['zipfilesize' ])
343
341
dialog = xbmcgui .Dialog ()
344
- download_dict = self ._parse_chromeos_recovery_conf ()
345
- if dialog .yesno (self ._language (30001 ), self ._language (30002 )) and dialog .yesno (self ._language (30001 ), self ._language (30006 ).format (self .sizeof_fmt (download_dict ['required_diskspace' ]))) and self ._widevine_eula ():
342
+ if dialog .yesno (self ._language (30001 ), self ._language (30002 )) and dialog .yesno (self ._language (30001 ), self ._language (30006 ).format (self .sizeof_fmt (required_diskspace ))) and self ._widevine_eula ():
346
343
if self ._os != 'Linux' :
347
344
dialog .ok (self ._language (30004 ), self ._language (30019 ).format (self ._os ))
348
345
return False
349
- if download_dict [ ' required_diskspace' ] >= self ._diskspace ():
346
+ if required_diskspace >= self ._diskspace ():
350
347
dialog .ok (self ._language (30004 ),
351
- self ._language (30018 ).format (self .sizeof_fmt (download_dict [ 'diskspace' ] )))
348
+ self ._language (30018 ).format (self .sizeof_fmt (required_diskspace )))
352
349
return False
353
350
if not self ._cmd_exists ('fdisk' ) and not self ._cmd_exists ('parted' ):
354
351
dialog .ok (self ._language (30004 ), self ._language (30020 ).format ('fdisk' , 'parted' ))
@@ -360,7 +357,7 @@ def _install_widevine_cdm_arm(self):
360
357
dialog .ok (self ._language (30004 ), self ._language (30021 ).format ('losetup' ))
361
358
return False
362
359
363
- self ._url = download_dict ['url' ]
360
+ self ._url = arm_device ['url' ]
364
361
downloaded = self ._http_request (download = True , message = self ._language (30022 ))
365
362
if downloaded :
366
363
dialog .ok (self ._language (30023 ), self ._language (30024 ))
0 commit comments