Skip to content

Commit 5b62319

Browse files
committed
Support vendor widevine library
This adds support for a vendor-supported Widevine library.
1 parent 047f0c4 commit 5b62319

File tree

17 files changed

+342
-113
lines changed

17 files changed

+342
-113
lines changed

lib/inputstreamhelper/__init__.py

+95-84
Large diffs are not rendered by default.

lib/inputstreamhelper/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def run(params):
2424
rollback()
2525

2626
elif len(params) > 4:
27-
log('invalid API call, too many parameters')
27+
log(4, 'invalid API call, too many parameters')
2828
else:
2929
ADDON.openSettings()
3030

lib/inputstreamhelper/kodiutils.py

+93-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ def __missing__(self, key):
1717
return '{' + key + '}'
1818

1919

20+
def addon_id():
21+
"""Return add-on ID"""
22+
return get_addon_info('id')
23+
24+
2025
def addon_profile():
2126
"""Cache and return add-on profile"""
2227
return to_unicode(xbmc.translatePath(ADDON.getAddonInfo('profile')))
@@ -178,7 +183,7 @@ def jsonrpc(*args, **kwargs):
178183

179184
# We do not accept both args and kwargs
180185
if args and kwargs:
181-
log('ERROR: Wrong use of jsonrpc()')
186+
log(4, 'ERROR: Wrong use of jsonrpc()')
182187
return None
183188

184189
# Process a list of actions
@@ -198,9 +203,13 @@ def jsonrpc(*args, **kwargs):
198203
return loads(xbmc.executeJSONRPC(dumps(kwargs)))
199204

200205

201-
def log(msg, level=xbmc.LOGDEBUG, **kwargs):
202-
''' InputStream Helper log method '''
203-
xbmc.log(msg=from_unicode('[{addon}] {msg}'.format(addon=get_addon_info('id'), msg=msg.format(**kwargs))), level=level)
206+
def log(level=0, message='', **kwargs):
207+
"""Log info messages to Kodi"""
208+
if kwargs:
209+
from string import Formatter
210+
message = Formatter().vformat(message, (), SafeDict(**kwargs))
211+
message = '[{addon}] {message}'.format(addon=addon_id(), message=message)
212+
xbmc.log(from_unicode(message), level)
204213

205214

206215
def kodi_to_ascii(string):
@@ -215,3 +224,83 @@ def kodi_to_ascii(string):
215224
string = string.replace('[COLOR yellow]', '')
216225
string = string.replace('[/COLOR]', '')
217226
return string
227+
228+
229+
def samefile(src, dest):
230+
"""Check if file is identical"""
231+
stat_src = stat_file(src)
232+
stat_dest = stat_file(dest)
233+
# Check if this is a hardlink
234+
if (stat_src.st_dev(), stat_src.st_ino()) == (stat_dest.st_dev(), stat_dest.st_ino()):
235+
return True
236+
237+
# Check file sizes
238+
if stat_src.st_size() != stat_dest.st_size():
239+
return False
240+
241+
# Check if this is a symlink
242+
from os.path import samefile as opsamefile
243+
if opsamefile(src, dest):
244+
return True
245+
246+
# Otherwise compare content (may be slow)
247+
with open(src, 'r') as srcfd, open(dest, 'r') as destfd:
248+
if srcfd.read() == destfd.read():
249+
return True
250+
251+
return False
252+
253+
254+
def copy(src, dest):
255+
"""Copy a file (using xbmcvfs)"""
256+
from xbmcvfs import copy as vfscopy
257+
log(2, "Copy file '{src}' to '{dest}'.", src=src, dest=dest)
258+
return vfscopy(src, dest)
259+
260+
261+
def delete(path):
262+
"""Remove a file (using xbmcvfs)"""
263+
from xbmcvfs import delete as vfsdelete
264+
log(2, "Delete file '{path}'.", path=path)
265+
return vfsdelete(path)
266+
267+
268+
def exists(path):
269+
"""Whether the path exists (using xbmcvfs)"""
270+
from xbmcvfs import exists as vfsexists
271+
return vfsexists(path)
272+
273+
274+
def hardlink(src, dest):
275+
"""Hardlink a file when possible, copy when needed"""
276+
from os import link
277+
278+
if exists(dest):
279+
delete(dest)
280+
281+
try:
282+
link(src, dest)
283+
except OSError:
284+
return copy(src, dest)
285+
log(2, "Hardlink file '{src}' to '{dest}'.", src=src, dest=dest)
286+
return True
287+
288+
289+
def mkdir(path):
290+
"""Create a directory (using xbmcvfs)"""
291+
from xbmcvfs import mkdir as vfsmkdir
292+
log(2, "Create directory '{path}'.", path=path)
293+
return vfsmkdir(path)
294+
295+
296+
def mkdirs(path):
297+
"""Create directory including parents (using xbmcvfs)"""
298+
from xbmcvfs import mkdirs as vfsmkdirs
299+
log(2, "Recursively create directory '{path}'.", path=path)
300+
return vfsmkdirs(path)
301+
302+
303+
def stat_file(path):
304+
"""Return information about a file (using xbmcvfs)"""
305+
from xbmcvfs import Stat
306+
return Stat(path)

resources/language/resource.language.de_de/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr ""
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr ""
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Widevine Version: [B]{version}[/B] [COLOR gray](zuletzt aktualisiert am [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Widevine CDM Pfad: [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Chrome OS Version: [B]{version}[/B]"
277281

resources/language/resource.language.el_gr/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr ""
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr ""
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Έκδοση Widevina: [B]{version}[/B] [COLOR gray](τελευταία ενημερωση [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Διαδρομη CDM του Widevine: [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Έκδοση του Chrome OS: [B]{version}[/B]"
277281

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
272272
msgstr ""
273273

274274
msgctxt "#30822"
275-
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
275+
msgid "Widevine version: [B]Supplied by vendor[/B]"
276276
msgstr ""
277277

278278
msgctxt "#30823"
279-
msgid "Widevine CDM path: [B]{path}[/B]"
279+
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
280280
msgstr ""
281281

282282
msgctxt "#30824"
283+
msgid "Widevine CDM path: [B]{path}[/B]"
284+
msgstr ""
285+
286+
msgctxt "#30825"
283287
msgid "Chrome OS version: [B]{version}[/B]"
284288
msgstr ""
285289

resources/language/resource.language.fr_fr/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr ""
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr ""
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Version Widevine : [B]{version}[/B] [COLOR gray](mise à jour le [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Emplacement de Widevine CDM : [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Version de ChromeOS : [B]{version}[/B]"
277281

resources/language/resource.language.hr_hr/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
272272
msgstr ""
273273

274274
msgctxt "#30822"
275+
msgid "Widevine version: [B]Supplied by vendor[/B]"
276+
msgstr ""
277+
278+
msgctxt "#30823"
275279
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
276280
msgstr "Widevine verzija: [B]{version}[/B] [COLOR gray](zadnja nadogradnja [B]{date}[/B])[/COLOR]"
277281

278-
msgctxt "#30823"
282+
msgctxt "#30824"
279283
msgid "Widevine CDM path: [B]{path}[/B]"
280284
msgstr "Widevine CDM mapa: [B]{path}[/B]"
281285

282-
msgctxt "#30824"
286+
msgctxt "#30825"
283287
msgid "Chrome OS version: [B]{version}[/B]"
284288
msgstr "Chrome OS verzija: [B]{version}[/B]"
285289

resources/language/resource.language.hu_hu/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
272272
msgstr ""
273273

274274
msgctxt "#30822"
275+
msgid "Widevine version: [B]Supplied by vendor[/B]"
276+
msgstr ""
277+
278+
msgctxt "#30823"
275279
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
276280
msgstr "Widevine verzió: [B]{version}[/B] [COLOR gray](utolsó frissítés [B]{date}[/B])[/COLOR]"
277281

278-
msgctxt "#30823"
282+
msgctxt "#30824"
279283
msgid "Widevine CDM path: [B]{path}[/B]"
280284
msgstr "Widevine CDM elérési út: [B]{path}[/B]"
281285

282-
msgctxt "#30824"
286+
msgctxt "#30825"
283287
msgid "Chrome OS version: [B]{version}[/B]"
284288
msgstr "Chrome OS verzió: [B]{version}[/B]"
285289

resources/language/resource.language.it_it/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr ""
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr ""
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Widevine: [B]{version}[/B] [COLOR gray](aggiornato il [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Widevine CDM: [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Chrome OS: [B]{version}[/B]"
277281

resources/language/resource.language.ja_JP/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
272272
msgstr ""
273273

274274
msgctxt "#30822"
275+
msgid "Widevine version: [B]Supplied by vendor[/B]"
276+
msgstr ""
277+
278+
msgctxt "#30823"
275279
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
276280
msgstr "Widevineバージョン:[B]{version}[/B] [COLOR gray](直近更新日[B]{date}[/B])[/COLOR]"
277281

278-
msgctxt "#30823"
282+
msgctxt "#30824"
279283
msgid "Widevine CDM path: [B]{path}[/B]"
280284
msgstr "Widevine CDM パス: [B]{path}[/B]"
281285

282-
msgctxt "#30824"
286+
msgctxt "#30825"
283287
msgid "Chrome OS version: [B]{version}[/B]"
284288
msgstr "Chrome OS バージョン: [B]{version}[/B]"
285289

resources/language/resource.language.ko_KR/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
272272
msgstr ""
273273

274274
msgctxt "#30822"
275+
msgid "Widevine version: [B]Supplied by vendor[/B]"
276+
msgstr ""
277+
278+
msgctxt "#30823"
275279
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
276280
msgstr "Widevine 버전: [B]{version}[/B] [COLOR gray]([B]{date}[/B]에 마지막으로 업데이트)[/COLOR]"
277281

278-
msgctxt "#30823"
282+
msgctxt "#30824"
279283
msgid "Widevine CDM path: [B]{path}[/B]"
280284
msgstr "Widevine CDM 경로: [B]{path}[/B]"
281285

282-
msgctxt "#30824"
286+
msgctxt "#30825"
283287
msgid "Chrome OS version: [B]{version}[/B]"
284288
msgstr "Chrome OS 버전: [B]{version}[/B]"
285289

resources/language/resource.language.nl_nl/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr "Widevine versie: [B]Ingebouwd in Android[/B]"
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr "Widevine versie: [B]Aangeleverd door vendor[/B]"
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Widevine versie: [B]{version}[/B] [COLOR gray](voor het laatst geüpdatet op [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Widevine CDM pad: [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Chrome OS versie: [B]{version}[/B]"
277281

resources/language/resource.language.ru_ru/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr ""
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr ""
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Версия Widevine: [B]{version}[/B] [COLOR gray](последнее обновление [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Путь к Widevine CDM: [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Версия Chrome OS: [B]{version}[/B]"
277281

resources/language/resource.language.sv_se/strings.po

+6-2
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
264264
msgstr ""
265265

266266
msgctxt "#30822"
267+
msgid "Widevine version: [B]Supplied by vendor[/B]"
268+
msgstr ""
269+
270+
msgctxt "#30823"
267271
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
268272
msgstr "Widevine-version: [B]{version}[/B] [COLOR gray](senast uppdaterad [B]{date}[/B])[/COLOR]"
269273

270-
msgctxt "#30823"
274+
msgctxt "#30824"
271275
msgid "Widevine CDM path: [B]{path}[/B]"
272276
msgstr "Widevine CDM-sökväg: [B]{path}[/B]"
273277

274-
msgctxt "#30824"
278+
msgctxt "#30825"
275279
msgid "Chrome OS version: [B]{version}[/B]"
276280
msgstr "Chrome OS-version: [B]{version}[/B]"
277281

0 commit comments

Comments
 (0)