Skip to content

Commit 671ddf9

Browse files
_supports_widevine() method
1 parent 468945e commit 671ddf9

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

lib/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'com.widevine.alpha': 'widevine'
1111
}
1212

13-
WIDEVINE_ARCHS = {
13+
ARCHS = {
1414
'x86_64': 'x86_64',
1515
'AMD64': 'x86_64',
1616
'x86': 'x86',
@@ -34,6 +34,14 @@
3434

3535
WIDEVINE_CDM_EXTENSIONS = ['.so', '.dll', '.dylib']
3636

37+
WIDEVINE_SUPPORTED_ARCHS = ['x86_64', 'x86', 'aarch64', 'aarch64_be', 'armv7', 'armv8', 'arm64']
38+
39+
WIDEVINE_SUPPORTED_OS = ['Linux', 'Windows', 'Darwin']
40+
41+
WIDEVINE_DOWNLOAD_UNAVAILABLE = ['aarch64', 'aarch64_be', 'armv7', 'armv8', 'arm64']
42+
43+
WIDEVINE_ANDROID_MINIMUM_KODI_VERSION = '18.0'
44+
3745
WIDEVINE_MINIMUM_KODI_VERSION = '17.4'
3846

3947
WIDEVINE_CDM_SOURCE = 'https://hg.mozilla.org/mozilla-central/raw-file/31465a03c03d1eec31cd4dd5d6b803724dcb29cd/toolkit/content/gmp-sources/widevinecdm.json'

lib/inputstreamhelper.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, protocol, drm=None):
1515
self._addon = xbmcaddon.Addon('script.module.inputstreamhelper')
1616
self._logging_prefix = '[%s-%s]' % (self._addon.getAddonInfo('id'), self._addon.getAddonInfo('version'))
1717
self._language = self._addon.getLocalizedString
18-
self._arch = platform.machine()
18+
self._arch = self._get_arch(platform.machine())
1919
self._os = platform.system()
2020
self._log('Platform information: {0}'.format(platform.uname()))
2121

@@ -32,6 +32,12 @@ def __init__(self, protocol, drm=None):
3232
class InputStreamException(Exception):
3333
pass
3434

35+
def _get_arch(self, arch):
36+
if arch in config.ARCHS:
37+
return config.ARCHS[arch]
38+
else:
39+
return arch
40+
3541
def _log(self, string):
3642
msg = '{0}: {1}'.format(self._logging_prefix, string)
3743
xbmc.log(msg=msg, level=xbmc.LOGDEBUG)
@@ -48,7 +54,7 @@ def _inputstream_version(self):
4854
addon = xbmcaddon.Addon(self._inputstream_addon)
4955
return addon.getAddonInfo('version')
5056

51-
def has_widevine_cdm(self):
57+
def _has_widevine_cdm(self):
5258
if xbmc.getCondVisibility('system.platform.android'): # widevine is built in on android
5359
return True
5460
else:
@@ -117,6 +123,28 @@ def _enable_inputstream(self):
117123
else:
118124
return True
119125

126+
def _supports_widevine(self):
127+
dialog = xbmcgui.Dialog()
128+
if xbmc.getCondVisibility('system.platform.android'):
129+
min_version = config.WIDEVINE_ANDROID_MINIMUM_KODI_VERSION
130+
else:
131+
min_version = config.WIDEVINE_MINIMUM_KODI_VERSION
132+
133+
if self._arch not in config.WIDEVINE_SUPPORTED_ARCHS:
134+
dialog.ok(self._language(30004), self._language(30007))
135+
return False
136+
if self._os not in config.WIDEVINE_SUPPORTED_OS:
137+
dialog.ok(self._language(30004), self._language(30011).format(self._os))
138+
return False
139+
if LooseVersion(min_version) > LooseVersion(self._kodi_version()):
140+
dialog.ok(self._language(30004), self._language(30010).format(min_version))
141+
return False
142+
if 'WindowsApps' in xbmc.translatePath('special://xbmcbin/'): # uwp is not supported
143+
dialog.ok(self._language(30004), self._language(30012))
144+
return False
145+
146+
return True
147+
120148
def check_for_inputstream(self):
121149
"""Ensures that selected InputStream add-on is installed and enabled.
122150
Displays a select dialog if add-on is installed but not enabled."""

resources/language/resource.language.en_gb/strings.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,15 @@ msgstr ""
4848
msgctxt "#30009"
4949
msgid "[B]{0}[/B] is not enabled. This add-on is required to play this content.[CR][CR]Would you like to enable [B]{1}[/B]?"
5050
msgstr ""
51+
52+
msgctxt "#30010"
53+
msgid "[B]Kodi {0}[/B] or higher is required for Widevine DRM content playback."
54+
msgstr ""
55+
56+
msgctxt "#30011"
57+
msgid "This operating system ([B]{0}[/B]) is not supported by Widevine DRM."
58+
msgstr ""
59+
60+
msgctxt "#30012"
61+
msgid "The Windows Store version of Kodi does not support Widevine DRM. Please use the installer from kodi.tv instead."
62+
msgstr ""

0 commit comments

Comments
 (0)