@@ -25,7 +25,6 @@ def __init__(self, protocol, drm=None):
25
25
26
26
self ._url = None
27
27
self ._download_path = None
28
- self ._bin_path = None
29
28
self ._mounted = False
30
29
self ._loop_dev = False
31
30
@@ -116,12 +115,12 @@ def _inputstream_version(self):
116
115
addon = xbmcaddon .Addon (self ._inputstream_addon )
117
116
return addon .getAddonInfo ('version' )
118
117
119
- def _parse_chromeos_offset (self ):
118
+ def _parse_chromeos_offset (self , bin_path ):
120
119
"""Calculate the Chrome OS losetup start offset using fdisk/parted."""
121
120
if self ._cmd_exists ('fdisk' ):
122
- cmd = ['fdisk' , self . _bin_path , '-l' ]
121
+ cmd = ['fdisk' , bin_path , '-l' ]
123
122
else : # parted
124
- cmd = ['parted' , '-s' , self . _bin_path , 'unit s print' ]
123
+ cmd = ['parted' , '-s' , bin_path , 'unit s print' ]
125
124
self ._log ('losetup calculation cmd: {0}' .format (cmd ))
126
125
127
126
output = subprocess .check_output (cmd )
@@ -136,9 +135,9 @@ def _parse_chromeos_offset(self):
136
135
self ._log ('Failed to calculate losetup offset.' )
137
136
return False
138
137
139
- def _losetup (self ):
138
+ def _losetup (self , bin_path ):
140
139
"""Setup Chrome OS loop device."""
141
- cmd = ['losetup' , config .LOOP_DEV , self . _bin_path , '-o' , self ._parse_chromeos_offset ()]
140
+ cmd = ['losetup' , config .LOOP_DEV , bin_path , '-o' , self ._parse_chromeos_offset (bin_path )]
142
141
subprocess .check_output (cmd )
143
142
self ._loop_dev = True
144
143
return True
@@ -322,7 +321,7 @@ def _install_widevine_cdm_x86(self):
322
321
if downloaded :
323
322
busy_dialog = xbmcgui .DialogBusy ()
324
323
busy_dialog .create ()
325
- self ._unzip_cdm ( )
324
+ self ._unzip ( self . _cdm_path () )
326
325
if self ._widevine_eula ():
327
326
self ._install_cdm ()
328
327
else :
@@ -367,7 +366,10 @@ def _install_widevine_cdm_arm(self):
367
366
dialog .ok (self ._language (30023 ), self ._language (30024 ))
368
367
busy_dialog = xbmcgui .DialogBusy ()
369
368
busy_dialog .create ()
370
- if not self ._unzip_bin () or not self ._losetup () or not self ._mnt_loop_dev ():
369
+
370
+ bin_filename = self ._url .split ('/' )[- 1 ].replace ('.zip' , '' )
371
+ bin_path = os .path .join (self ._temp_path (), bin_filename )
372
+ if not self ._unzip (self ._temp_path (), bin_filename ) or not self ._losetup (bin_path ) or not self ._mnt_loop_dev ():
371
373
self ._cleanup ()
372
374
busy_dialog .close ()
373
375
return False
@@ -425,18 +427,18 @@ def _install_cdm(self):
425
427
426
428
return True
427
429
428
- def _unzip_bin (self ):
429
- zip_obj = zipfile .ZipFile (self ._download_path )
430
- for filename in zip_obj .namelist ():
431
- if filename .endswith ('.bin' ):
432
- zip_obj .extract (filename , self ._temp_path ())
433
- self ._bin_path = os .path .join (self ._temp_path (), filename )
434
- return True
435
-
436
- def _unzip_cdm (self ):
430
+ def _unzip (self , unzip_dir , file_to_unzip = None ):
431
+ """Unzip files to specified path."""
437
432
zip_obj = zipfile .ZipFile (self ._download_path )
438
- zip_obj .extractall (self ._cdm_path ())
439
- return True
433
+ if file_to_unzip :
434
+ for filename in zip_obj .namelist ():
435
+ if filename == file_to_unzip :
436
+ zip_obj .extract (filename , unzip_dir )
437
+ return True
438
+ return False
439
+ else : # extract all files
440
+ zip_obj .extractall (unzip_dir )
441
+ return True
440
442
441
443
def _cleanup (self ):
442
444
"""Clean up after Widevine DRM installation."""
0 commit comments