Skip to content

Commit d0c56c3

Browse files
Add some docstrings and more logging
1 parent c0dde4c commit d0c56c3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/inputstreamhelper.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,19 @@ def _supports_widevine(self):
174174
min_version = config.WIDEVINE_MINIMUM_KODI_VERSION
175175

176176
if self._arch not in config.WIDEVINE_SUPPORTED_ARCHS:
177+
self._log('Unsupported Widevine architecture found: {0}'.format(self._arch))
177178
dialog.ok(self._language(30004), self._language(30007))
178179
return False
179180
if self._os not in config.WIDEVINE_SUPPORTED_OS:
181+
self._log('Unsupported Widevine OS found: {0}'.format(self._os))
180182
dialog.ok(self._language(30004), self._language(30011).format(self._os))
181183
return False
182184
if LooseVersion(min_version) > LooseVersion(self._kodi_version()):
185+
self._log('Unsupported Kodi version for Widevine: {0}'.format(self._kodi_version()))
183186
dialog.ok(self._language(30004), self._language(30010).format(min_version))
184187
return False
185188
if 'WindowsApps' in xbmc.translatePath('special://xbmcbin/'): # uwp is not supported
189+
self.log('Unsupported UWP Kodi version detected.')
186190
dialog.ok(self._language(30004), self._language(30012))
187191
return False
188192

@@ -192,8 +196,7 @@ def _install_widevine_cdm(self):
192196
dialog = xbmcgui.Dialog()
193197
download_path = os.path.join(xbmc.translatePath('special://temp'), 'widevine_cdm.zip')
194198
cdm_platform = config.WIDEVINE_DOWNLOAD_MAP[self._arch][self._os]
195-
cdm_source = json.loads(self._http_request(config.WIDEVINE_CDM_SOURCE))['vendors']['gmp-widevinecdm'][
196-
'platforms']
199+
cdm_source = json.loads(self._http_request(config.WIDEVINE_CDM_SOURCE))['vendors']['gmp-widevinecdm']['platforms']
197200
cdm_zip_url = cdm_source[cdm_platform]['fileUrl']
198201

199202
downloaded = self._http_request(cdm_zip_url, download=True, download_path=download_path)
@@ -211,16 +214,19 @@ def _unzip_widevine_cdm(self, zip_path):
211214
busy_dialog.create()
212215
for filename in zip_obj.namelist():
213216
if filename.endswith(config.WIDEVINE_CDM_EXTENSIONS):
217+
self._log('Widevine CDM found at: {0}'.format(os.path.join(zip_path, filename)))
214218
zip_obj.extract(filename, self._cdm_path())
215219
busy_dialog.close()
216220
return True
217221

218222
busy_dialog.close()
219223
dialog = xbmcgui.Dialog()
220224
dialog.ok(self._language(30004), self._language(30016))
225+
self._log('Failed to find Widevine CDM file in {0}'.format(zip_path))
221226
return False
222227

223228
def check_for_drm(self):
229+
"""Main function for ensuring that specified DRM system is installed and available."""
224230
if self.drm:
225231
if self.drm == 'widevine':
226232
if not self._supports_widevine():
@@ -235,9 +241,8 @@ def check_for_drm(self):
235241

236242
return True
237243

238-
def check_for_inputstream(self):
239-
"""Ensures that selected InputStream add-on is installed, enabled and
240-
that specified DRM system is installed."""
244+
def check_inputstream(self):
245+
"""Main function. Ensures that all components are available for InputStream add-on playback."""
241246
dialog = xbmcgui.Dialog()
242247
if not self._has_inputstream():
243248
self._log('{0} is not installed.'.format(self._inputstream_addon))
@@ -262,4 +267,5 @@ def supports_hls(self):
262267
if self.protocol == 'hls' and LooseVersion(self._inputstream_version()) >= LooseVersion(config.HLS_MINIMUM_IA_VERSION):
263268
return True
264269
else:
270+
self._log('HLS is not supported on {0} version {1}'.format(self._inputstream_addon), self._inputstream_version())
265271
return False

0 commit comments

Comments
 (0)