@@ -136,42 +136,48 @@ def _load_widevine_config(cls):
136
136
return loads (config_file .read ())
137
137
138
138
@classmethod
139
- def _has_vendor_widevine (cls ):
140
- """Whether the system has a vendor-supplied widevine CDM"""
141
- widevine_cdm_filename = config .WIDEVINE_CDM_FILENAME [system_os ()]
142
- if widevine_cdm_filename is None :
143
- return False
144
-
145
- widevine_path = os .path .join (cls ._ia_cdm_path (), widevine_cdm_filename )
146
- vendor_widevine_path = '{0}_vendor{1}' .format (* os .path .splitext (widevine_path ))
147
- if exists (vendor_widevine_path ):
148
- return True
139
+ def _widevinecdm_path (cls ):
140
+ """Get full widevine path"""
141
+ widevinecdm_filename = config .WIDEVINE_CDM_FILENAME [system_os ()]
142
+ if widevinecdm_filename is None :
143
+ return None
144
+ if cls ._ia_cdm_path () is None :
145
+ return None
146
+ return os .path .join (cls ._ia_cdm_path (), widevinecdm_filename )
149
147
150
- return False
148
+ @classmethod
149
+ def _vendor_widevinecdm_path (cls ):
150
+ widevinecdm_path = cls ._widevinecdm_path ()
151
+ return '{0}_vendor{1}' .format (* os .path .splitext (widevinecdm_path ))
151
152
152
153
@classmethod
153
- def _widevine_path (cls ):
154
- """Get full widevine path """
155
- widevine_cdm_filename = config . WIDEVINE_CDM_FILENAME [ system_os ()]
156
- if widevine_cdm_filename is None :
154
+ def _has_widevinecdm (cls ):
155
+ """Whether the system has a widevine CDM """
156
+ widevinecdm_path = cls . _widevinecdm_path ()
157
+ if widevinecdm_path is None :
157
158
return False
159
+ if not exists (widevinecdm_path ):
160
+ return False
161
+ return True
158
162
159
- if cls ._ia_cdm_path ():
160
- widevine_path = os .path .join (cls ._ia_cdm_path (), widevine_cdm_filename )
161
-
162
- # Support vendor-supplied Widevine CDM
163
- vendor_widevine_path = '{0}_vendor{1}' .format (* os .path .splitext (widevine_path ))
164
- if exists (vendor_widevine_path ):
165
- if exists (widevine_path ):
166
- if not samefile (vendor_widevine_path , widevine_path ):
167
- hardlink (vendor_widevine_path , widevine_path )
168
- else :
169
- hardlink (vendor_widevine_path , widevine_path )
170
-
171
- if exists (widevine_path ):
172
- return widevine_path
163
+ @classmethod
164
+ def _has_vendor_widevinecdm (cls ):
165
+ """Whether the system has a vendor-supplied widevine CDM"""
166
+ vendor_widevinecdm_path = cls ._vendor_widevinecdm_path ()
167
+ if not exists (vendor_widevinecdm_path ):
168
+ return False
169
+ return True
173
170
174
- return False
171
+ @classmethod
172
+ def _hardlink_vendor_widevinecdm (cls ):
173
+ """Hardlink vendor Widevine into place"""
174
+ vendor_widevinecdm_path = cls ._vendor_widevinecdm_path ()
175
+ if not exists (vendor_widevinecdm_path ):
176
+ return
177
+ widevinecdm_path = cls ._widevinecdm_path ()
178
+ if exists (widevinecdm_path ) and samefile (vendor_widevinecdm_path , widevinecdm_path ):
179
+ return
180
+ hardlink (vendor_widevinecdm_path , widevinecdm_path )
175
181
176
182
@classmethod
177
183
def _kodi_version (cls ):
@@ -268,7 +274,7 @@ def _inputstream_version(self):
268
274
269
275
@staticmethod
270
276
def _get_lib_version (path ):
271
- if not path :
277
+ if not path or not exists ( path ) :
272
278
return '(Not found)'
273
279
import re
274
280
with open (path , 'rb' ) as library :
@@ -373,11 +379,13 @@ def _mnt_loop_dev(self):
373
379
374
380
def _has_widevine (self ):
375
381
"""Checks if Widevine CDM is installed on system."""
376
- if system_os () == 'Android' : # widevine is built in on android
382
+ if system_os () == 'Android' : # Widevine is built into Android
377
383
return True
378
384
379
- if self ._widevine_path ():
380
- log (0 , 'Found Widevine binary at {path}' , path = self ._widevine_path ())
385
+ self ._hardlink_vendor_widevinecdm () # If vendor Widevine is present, hardlink into place
386
+
387
+ if self ._has_widevinecdm ():
388
+ log (0 , 'Found Widevine binary at {path}' , path = self ._widevinecdm_path ())
381
389
return True
382
390
383
391
log (3 , 'Widevine is not installed.' )
@@ -782,10 +790,10 @@ def install_widevine(self):
782
790
783
791
def remove_widevine (self ):
784
792
"""Removes Widevine CDM"""
785
- widevinecdm = self ._widevine_path ()
786
- if widevinecdm and exists ( widevinecdm ):
787
- log (0 , 'Remove Widevine CDM at {path}' , path = widevinecdm )
788
- delete (widevinecdm )
793
+ if self ._has_widevinecdm ():
794
+ widevinecdm_path = self . _widevinecdm_path ()
795
+ log (0 , 'Remove Widevine CDM at {path}' , path = widevinecdm_path )
796
+ delete (widevinecdm_path )
789
797
notification (localize (30037 ), localize (30052 )) # Success! Widevine successfully removed.
790
798
return True
791
799
notification (localize (30004 ), localize (30053 )) # Error. Widevine CDM not found.
@@ -881,12 +889,13 @@ def _missing_widevine_libs(self):
881
889
return None
882
890
883
891
if self ._cmd_exists ('ldd' ):
884
- if not os .access (self ._widevine_path (), os .X_OK ):
885
- log (0 , 'Changing {path} permissions to 744.' , path = self ._widevine_path ())
886
- os .chmod (self ._widevine_path (), 0o744 )
892
+ widevinecdm_path = self ._widevinecdm_path ()
893
+ if not os .access (widevinecdm_path , os .X_OK ):
894
+ log (0 , 'Changing {path} permissions to 744.' , path = widevinecdm_path )
895
+ os .chmod (widevinecdm_path , 0o744 )
887
896
888
897
missing_libs = []
889
- cmd = ['ldd' , self . _widevine_path () ]
898
+ cmd = ['ldd' , widevinecdm_path ]
890
899
output = self ._run_cmd (cmd , sudo = False )
891
900
if output ['success' ]:
892
901
for line in output ['output' ].splitlines ():
@@ -919,7 +928,7 @@ def _check_widevine(self):
919
928
if system_os () == 'Android' : # no checks needed for Android
920
929
return True
921
930
922
- if self ._has_vendor_widevine (): # no checks needed for vendor-supplied Widevine
931
+ if self ._has_vendor_widevinecdm (): # no checks needed for vendor-supplied Widevine
923
932
return True
924
933
925
934
if not os .path .exists (self ._widevine_config_path ()):
@@ -1073,12 +1082,12 @@ def info_dialog(self):
1073
1082
text += localize (30820 ) + '\n ' # Widevine information
1074
1083
if system_os () == 'Android' :
1075
1084
text += ' - ' + localize (30821 ) + '\n '
1076
- elif self ._has_vendor_widevine ():
1077
- text += ' - ' + localize (30822 , version = self ._get_lib_version (self ._widevine_path ())) + '\n '
1085
+ elif self ._has_vendor_widevinecdm ():
1086
+ text += ' - ' + localize (30822 , version = self ._get_lib_version (self ._widevinecdm_path ())) + '\n '
1078
1087
else :
1079
1088
from datetime import datetime
1080
1089
wv_updated = datetime .fromtimestamp (float (get_setting ('last_update' ))).strftime ("%Y-%m-%d %H:%M" ) if get_setting ('last_update' ) else 'Never'
1081
- text += ' - ' + localize (30823 , version = self ._get_lib_version (self ._widevine_path ()), date = wv_updated ) + '\n '
1090
+ text += ' - ' + localize (30823 , version = self ._get_lib_version (self ._widevinecdm_path ()), date = wv_updated ) + '\n '
1082
1091
text += ' - ' + localize (30824 , path = self ._ia_cdm_path ()) + '\n '
1083
1092
1084
1093
if self ._arch () in ('arm' , 'arm64' ): # Chrome OS version
0 commit comments