Skip to content

Commit 60505b6

Browse files
Initial commit
0 parents  commit 60505b6

File tree

10 files changed

+179
-0
lines changed

10 files changed

+179
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Nils Emil Svensson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# dummy file to init the directory

addon.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<addon id="script.module.inputstreamhelper"
3+
name="InputStream Helper"
4+
version="0.1.0"
5+
provider-name="emilsvennesson">
6+
<requires>
7+
<import addon="xbmc.python" version="2.1.0"/>
8+
</requires>
9+
<extension library="lib" point="xbmc.python.module"/>
10+
<extension point="xbmc.addon.metadata">
11+
<description lang="en_GB">A Kodi module that makes life easier for add-on developers who are relying on InputStream based add-ons and DRM playback.</summary>
12+
<platform>all</platform>
13+
<license>The MIT License (MIT)</license>
14+
<source>https://github.com/emilsvennesson/script.module.inputstreamhelper</source>
15+
<assets>
16+
<icon>resources/art/icon.png</icon>
17+
</assets>
18+
</extension>
19+
</addon>

lib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# dummy file to init the directory

lib/config.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
INPUTSTREAM_PROTOCOLS = {
2+
'mpd': 'inputstream.adaptive',
3+
'dash': 'inputstream.adaptive',
4+
'ism': 'inputstream.adaptive',
5+
'hls': 'inputstream.adaptive',
6+
'rtmp': 'inputstream.rtmp'
7+
}
8+
9+
DRM_SCHEMES = {
10+
'widevine': 'widevine',
11+
'com.widevine.alpha': 'widevine'
12+
}
13+
14+
WIDEVINE_ARCHS = {
15+
'x86_64': 'x86_64',
16+
'AMD64': 'x86_64',
17+
'x86': 'x86',
18+
'i386': 'x86',
19+
'i686': 'x86'
20+
}
21+
22+
WIDEVINE_DOWNLOAD_MAP = {
23+
'x86_64':
24+
{
25+
'Linux': 'Linux_x86_64-gcc3',
26+
'Windows': 'WINNT_x86-msvc',
27+
'Darwin': 'Darwin_x86_64-gcc3-u-i386-x86_64'},
28+
'x86':
29+
{
30+
'Linux': 'Linux_x86-gcc3',
31+
'Windows': 'WINNT_x86-msvc',
32+
'Darwin': 'Darwin_x86_64-gcc3-u-i386-x86_64'
33+
}
34+
}
35+
36+
WIDEVINE_CDM_EXTENSIONS = ['.so', '.dll', '.dylib']
37+
38+
WIDEVINE_MINIMUM_KODI_VERSION = '17.4'
39+
40+
WIDEVINE_CDM_SOURCE = 'https://hg.mozilla.org/mozilla-central/raw-file/31465a03c03d1eec31cd4dd5d6b803724dcb29cd/toolkit/content/gmp-sources/widevinecdm.json'
41+
42+
HLS_MINIMUM_IA_VERSION = '2.0.11'

lib/inputstreamhelper.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import platform
3+
import zipfile
4+
import json
5+
6+
import config
7+
import xbmc
8+
import xbmcaddon
9+
import xbmcgui
10+
11+
12+
class InputStreamHelper(object):
13+
def __init__(self, protocol, drm=None):
14+
self._addon = xbmcaddon.Addon('script.module.inputstreamhelper')
15+
self._logging_prefix = '[%s-%s]' % (self._addon.getAddonInfo('id'), self._addon.getAddonInfo('version'))
16+
self._language = self._addon.getLocalizedString
17+
self._arch = platform.machine()
18+
self._os = platform.system()
19+
self._log('Platform information: {0}'.format(platform.uname()))
20+
21+
self.protocol = protocol
22+
self.drm = drm
23+
if self.protocol not in config.INPUTSTREAM_PROTOCOLS:
24+
raise self.InputStreamException('UnsupportedProtocol')
25+
else:
26+
self._inputstream_addon = config.INPUTSTREAM_PROTOCOLS[self.protocol]
27+
28+
class InputStreamException(Exception):
29+
pass
30+
31+
def _log(self, string):
32+
msg = '{0}: {1}'.format(self._logging_prefix, string)
33+
xbmc.log(msg=msg, level=xbmc.LOGDEBUG)
34+
35+
def _cdm_path(self):
36+
addon = xbmcaddon.Addon('inputstream.adaptive')
37+
return xbmc.translatePath(addon.getSetting('DECRYPTERPATH'))
38+
39+
def has_widevine_cdm(self):
40+
if xbmc.getCondVisibility('system.platform.android'): # widevine is built in on android
41+
return True
42+
else:
43+
for filename in os.listdir(self._cdm_path()):
44+
if 'widevine' in filename and filename.endswith(config.WIDEVINE_CDM_EXTENSIONS):
45+
self._log('Found Widevine binary at {0}'.format(os.path.join(self._cdm_path(), filename)))
46+
return True
47+
48+
self.log('Widevine is not installed.')
49+
return False

resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# dummy file to init the directory

resources/art/icon.png

36.8 KB
Loading
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# script.widevine language file
2+
msgid ""
3+
msgstr ""
4+
"Project-Id-Version: script.widevine\n"
5+
"Report-Msgid-Bugs-To: https://github.com/emilsvennesson/script.module.inputstreamhelper\n"
6+
"POT-Creation-Date: 2013-11-18 16:15+0000\n"
7+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9+
"Language-Team: English\n"
10+
"MIME-Version: 1.0\n"
11+
"Content-Type: text/plain; charset=UTF-8\n"
12+
"Content-Transfer-Encoding: 8bit\n"
13+
"Language: en\n"
14+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
15+
16+
msgctxt "#30001"
17+
msgid "Information"
18+
msgstr ""
19+
20+
msgctxt "#30002"
21+
msgid "You do not have Widevine DRM installed. This is required for playback of this content.[CR][CR]Would you like to install Widevine DRM?"
22+
msgstr ""
23+
24+
msgctxt "#30003"
25+
msgid "Widevine DRM was successfully installed!"
26+
msgstr ""
27+
28+
msgctxt "#30004"
29+
msgid "Error"
30+
msgstr ""
31+
32+
msgctxt "#30005"
33+
msgid "An error occurred while installing Widevine DRM. Please enable debug logging and file a bug report on [B]github.com/emilsvennesson/script.module.inputstreamhelper[/B]."
34+
msgstr ""
35+
36+
msgctxt "#30006"
37+
msgid "Widevine DRM is supported on this system architecture but is not possible to automatically install due to legal distributing issues. Hint: Google might be able to help you out! :-)"
38+
msgstr ""
39+
40+
msgctxt "#30007"
41+
msgid "Widevine DRM is unfortunately not available on this system architecture."
42+
msgstr ""

0 commit comments

Comments
 (0)