@@ -22,14 +22,16 @@ def __init__(self, protocol, drm=None):
22
22
self ._log ('Platform information: {0}' .format (platform .uname ()))
23
23
24
24
self .protocol = protocol
25
+ self .drm = drm
25
26
if self .protocol not in config .INPUTSTREAM_PROTOCOLS :
26
27
raise self .InputStreamException ('UnsupportedProtocol' )
27
28
else :
28
29
self ._inputstream_addon = config .INPUTSTREAM_PROTOCOLS [self .protocol ]
29
- if not drm or drm not in config .DRM_SCHEMES :
30
- raise self .InputStreamException ('UnsupportedDRMScheme' )
31
- else :
32
- self .drm = config .DRM_SCHEMES [drm ]
30
+ if self .drm :
31
+ if self .drm not in config .DRM_SCHEMES :
32
+ raise self .InputStreamException ('UnsupportedDRMScheme' )
33
+ else :
34
+ self .drm = config .DRM_SCHEMES [drm ]
33
35
34
36
class InputStreamException (Exception ):
35
37
pass
@@ -103,7 +105,7 @@ def _http_request(self, url, download=False, download_path=None):
103
105
for chunk in req .iter_content (chunk_size = 1024 ):
104
106
f .write (chunk )
105
107
dl += len (chunk )
106
- percent = int (dl * 100 / total_length )
108
+ percent = int (dl * 100 / total_length )
107
109
if progress_dialog .iscanceled ():
108
110
progress_dialog .close ()
109
111
req .close ()
@@ -114,7 +116,6 @@ def _http_request(self, url, download=False, download_path=None):
114
116
else :
115
117
return req .content
116
118
117
-
118
119
def _has_inputstream (self ):
119
120
"""Checks if selected InputStream add-on is installed."""
120
121
payload = {
@@ -191,7 +192,8 @@ def _install_widevine_cdm(self):
191
192
dialog = xbmcgui .Dialog ()
192
193
download_path = os .path .join (xbmc .translatePath ('special://temp' ), 'widevine_cdm.zip' )
193
194
cdm_platform = config .WIDEVINE_DOWNLOAD_MAP [self ._arch ][self ._os ]
194
- cdm_source = json .loads (self ._http_request (config .WIDEVINE_CDM_SOURCE ))['vendors' ]['gmp-widevinecdm' ]['platforms' ]
195
+ cdm_source = json .loads (self ._http_request (config .WIDEVINE_CDM_SOURCE ))['vendors' ]['gmp-widevinecdm' ][
196
+ 'platforms' ]
195
197
cdm_zip_url = cdm_source [cdm_platform ]['fileUrl' ]
196
198
197
199
downloaded = self ._http_request (cdm_zip_url , download = True , download_path = download_path )
@@ -218,36 +220,46 @@ def _unzip_widevine_cdm(self, zip_path):
218
220
dialog .ok (self ._language (30004 ), self ._language (30016 ))
219
221
return False
220
222
221
- def check_for_widevine (self ):
222
- if not self ._supports_widevine ():
223
- return False
224
- if not self ._has_widevine_cdm ():
225
- dialog = xbmcgui .Dialog ()
226
- ok = dialog .yesno (self ._language (30001 ), self ._language (30002 ))
227
- if ok :
228
- return self ._install_widevine_cdm ()
229
- else :
230
- return False
223
+ def check_for_drm (self ):
224
+ if self .drm :
225
+ if self .drm == 'widevine' :
226
+ if not self ._supports_widevine ():
227
+ return False
228
+ if not self ._has_widevine_cdm ():
229
+ dialog = xbmcgui .Dialog ()
230
+ ok = dialog .yesno (self ._language (30001 ), self ._language (30002 ))
231
+ if ok :
232
+ return self ._install_widevine_cdm ()
233
+ else :
234
+ return False
235
+ else :
236
+ return True
231
237
else :
238
+ self ._log ('No DRM has been specified.' )
232
239
return True
233
240
234
241
def check_for_inputstream (self ):
235
- """Ensures that selected InputStream add-on is installed and enabled.
236
- Displays a select dialog if add-on is installed but not enabled ."""
242
+ """Ensures that selected InputStream add-on is installed, enabled and
243
+ that specified DRM system is installed."""
237
244
dialog = xbmcgui .Dialog ()
238
245
if not self ._has_inputstream ():
239
246
self ._log ('{0} is not installed.' .format (self ._inputstream_addon ))
240
247
dialog .ok (self ._language (30004 ), self ._language (30008 ).format (self ._inputstream_addon ))
248
+ return False
241
249
elif not self ._inputstream_enabled ():
242
250
self ._log ('{0} is not enabled.' .format (self ._inputstream_addon ))
243
- ok = dialog .yesno (self ._language (30001 ), self ._language (30009 ).format (self ._inputstream_addon , self ._inputstream_addon ))
251
+ ok = dialog .yesno (self ._language (30001 ),
252
+ self ._language (30009 ).format (self ._inputstream_addon , self ._inputstream_addon ))
244
253
if ok :
245
- return self ._enable_inputstream ()
254
+ if not self ._enable_inputstream ():
255
+ return False
246
256
else :
247
257
return False
258
+ elif self .protocol == 'hls' :
259
+ return self .supports_hls ()
248
260
else :
249
261
self ._log ('{0} is installed and enabled.' .format (self ._inputstream_addon ))
250
- return True
262
+ return self . check_for_drm ()
251
263
252
264
def supports_hls (self ):
253
265
if self .protocol == 'hls' and LooseVersion (self ._inputstream_version ()) >= LooseVersion (config .HLS_MINIMUM_IA_VERSION ):
0 commit comments