Skip to content

Commit

Permalink
Support vendor widevine library
Browse files Browse the repository at this point in the history
This adds support for a vendor-supported Widevine library.
  • Loading branch information
dagwieers committed Dec 23, 2019
1 parent 047f0c4 commit 5b62319
Show file tree
Hide file tree
Showing 17 changed files with 342 additions and 113 deletions.
179 changes: 95 additions & 84 deletions lib/inputstreamhelper/__init__.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/inputstreamhelper/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run(params):
rollback()

elif len(params) > 4:
log('invalid API call, too many parameters')
log(4, 'invalid API call, too many parameters')
else:
ADDON.openSettings()

Expand Down
97 changes: 93 additions & 4 deletions lib/inputstreamhelper/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def __missing__(self, key):
return '{' + key + '}'


def addon_id():
"""Return add-on ID"""
return get_addon_info('id')


def addon_profile():
"""Cache and return add-on profile"""
return to_unicode(xbmc.translatePath(ADDON.getAddonInfo('profile')))
Expand Down Expand Up @@ -178,7 +183,7 @@ def jsonrpc(*args, **kwargs):

# We do not accept both args and kwargs
if args and kwargs:
log('ERROR: Wrong use of jsonrpc()')
log(4, 'ERROR: Wrong use of jsonrpc()')
return None

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


def log(msg, level=xbmc.LOGDEBUG, **kwargs):
''' InputStream Helper log method '''
xbmc.log(msg=from_unicode('[{addon}] {msg}'.format(addon=get_addon_info('id'), msg=msg.format(**kwargs))), level=level)
def log(level=0, message='', **kwargs):
"""Log info messages to Kodi"""
if kwargs:
from string import Formatter
message = Formatter().vformat(message, (), SafeDict(**kwargs))
message = '[{addon}] {message}'.format(addon=addon_id(), message=message)
xbmc.log(from_unicode(message), level)


def kodi_to_ascii(string):
Expand All @@ -215,3 +224,83 @@ def kodi_to_ascii(string):
string = string.replace('[COLOR yellow]', '')
string = string.replace('[/COLOR]', '')
return string


def samefile(src, dest):
"""Check if file is identical"""
stat_src = stat_file(src)
stat_dest = stat_file(dest)
# Check if this is a hardlink
if (stat_src.st_dev(), stat_src.st_ino()) == (stat_dest.st_dev(), stat_dest.st_ino()):
return True

# Check file sizes
if stat_src.st_size() != stat_dest.st_size():
return False

# Check if this is a symlink
from os.path import samefile as opsamefile
if opsamefile(src, dest):
return True

# Otherwise compare content (may be slow)
with open(src, 'r') as srcfd, open(dest, 'r') as destfd:
if srcfd.read() == destfd.read():
return True

return False


def copy(src, dest):
"""Copy a file (using xbmcvfs)"""
from xbmcvfs import copy as vfscopy
log(2, "Copy file '{src}' to '{dest}'.", src=src, dest=dest)
return vfscopy(src, dest)


def delete(path):
"""Remove a file (using xbmcvfs)"""
from xbmcvfs import delete as vfsdelete
log(2, "Delete file '{path}'.", path=path)
return vfsdelete(path)


def exists(path):
"""Whether the path exists (using xbmcvfs)"""
from xbmcvfs import exists as vfsexists
return vfsexists(path)


def hardlink(src, dest):
"""Hardlink a file when possible, copy when needed"""
from os import link

if exists(dest):
delete(dest)

try:
link(src, dest)
except OSError:
return copy(src, dest)
log(2, "Hardlink file '{src}' to '{dest}'.", src=src, dest=dest)
return True


def mkdir(path):
"""Create a directory (using xbmcvfs)"""
from xbmcvfs import mkdir as vfsmkdir
log(2, "Create directory '{path}'.", path=path)
return vfsmkdir(path)


def mkdirs(path):
"""Create directory including parents (using xbmcvfs)"""
from xbmcvfs import mkdirs as vfsmkdirs
log(2, "Recursively create directory '{path}'.", path=path)
return vfsmkdirs(path)


def stat_file(path):
"""Return information about a file (using xbmcvfs)"""
from xbmcvfs import Stat
return Stat(path)
8 changes: 6 additions & 2 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine Version: [B]{version}[/B] [COLOR gray](zuletzt aktualisiert am [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM Pfad: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS Version: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.el_gr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Έκδοση Widevina: [B]{version}[/B] [COLOR gray](τελευταία ενημερωση [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Διαδρομη CDM του Widevine: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Έκδοση του Chrome OS: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

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

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

msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr ""

msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr ""

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.fr_fr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Version Widevine : [B]{version}[/B] [COLOR gray](mise à jour le [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Emplacement de Widevine CDM : [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Version de ChromeOS : [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.hr_hr/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine verzija: [B]{version}[/B] [COLOR gray](zadnja nadogradnja [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM mapa: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS verzija: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.hu_hu/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine verzió: [B]{version}[/B] [COLOR gray](utolsó frissítés [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM elérési út: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS verzió: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.it_it/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine: [B]{version}[/B] [COLOR gray](aggiornato il [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.ja_JP/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevineバージョン:[B]{version}[/B] [COLOR gray](直近更新日[B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM パス: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS バージョン: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.ko_KR/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine 버전: [B]{version}[/B] [COLOR gray]([B]{date}[/B]에 마지막으로 업데이트)[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM 경로: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS 버전: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr "Widevine versie: [B]Ingebouwd in Android[/B]"

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr "Widevine versie: [B]Aangeleverd door vendor[/B]"

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine versie: [B]{version}[/B] [COLOR gray](voor het laatst geüpdatet op [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM pad: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS versie: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.ru_ru/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Версия Widevine: [B]{version}[/B] [COLOR gray](последнее обновление [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Путь к Widevine CDM: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Версия Chrome OS: [B]{version}[/B]"

Expand Down
8 changes: 6 additions & 2 deletions resources/language/resource.language.sv_se/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,18 @@ msgid "Widevine version: [B]Built into Android[/B]"
msgstr ""

msgctxt "#30822"
msgid "Widevine version: [B]Supplied by vendor[/B]"
msgstr ""

msgctxt "#30823"
msgid "Widevine version: [B]{version}[/B] [COLOR gray](last updated on [B]{date}[/B])[/COLOR]"
msgstr "Widevine-version: [B]{version}[/B] [COLOR gray](senast uppdaterad [B]{date}[/B])[/COLOR]"

msgctxt "#30823"
msgctxt "#30824"
msgid "Widevine CDM path: [B]{path}[/B]"
msgstr "Widevine CDM-sökväg: [B]{path}[/B]"

msgctxt "#30824"
msgctxt "#30825"
msgid "Chrome OS version: [B]{version}[/B]"
msgstr "Chrome OS-version: [B]{version}[/B]"

Expand Down
Loading

0 comments on commit 5b62319

Please sign in to comment.