From b05cac9ca84150d1885fd0b073789d49fe408148 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 25 Sep 2019 21:03:23 +0200 Subject: [PATCH] Autoinstall Widevine updates This adds a feature to enable automatic installation of Widevine. --- lib/inputstreamhelper/__init__.py | 11 ++++++----- lib/inputstreamhelper/kodiutils.py | 8 ++++++-- resources/settings.xml | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/inputstreamhelper/__init__.py b/lib/inputstreamhelper/__init__.py index 1d09b640..f3035c00 100644 --- a/lib/inputstreamhelper/__init__.py +++ b/lib/inputstreamhelper/__init__.py @@ -586,7 +586,8 @@ def _install_widevine_arm(self): # pylint: disable=too-many-statements return '' required_diskspace = int(arm_device['filesize']) + int(arm_device['zipfilesize']) if yesno_dialog(localize(30001), # Due to distributing issues, this takes a long time - localize(30006, diskspace=self._sizeof_fmt(required_diskspace))) and self._widevine_eula(): + localize(30006, diskspace=self._sizeof_fmt(required_diskspace)), + autoanswer=True) and self._widevine_eula(): if system_os() != 'Linux': ok_dialog(localize(30004), localize(30019, os=system_os())) return False @@ -614,7 +615,7 @@ def _install_widevine_arm(self): # pylint: disable=too-many-statements if os.getuid() != 0 and not yesno_dialog(localize(30001), # Ask for permission to run cmds as root localize(30030, cmds=', '.join(root_cmds)), - nolabel=localize(30028), yeslabel=localize(30027)): + nolabel=localize(30028), yeslabel=localize(30027), autoanswer=True): return False # Clean up any remaining mounts @@ -720,7 +721,7 @@ def _update_widevine(self): if LooseVersion(latest_version) > LooseVersion(current_version): log('There is an update available for {component}', component=component) - if yesno_dialog(localize(30040), localize(30033), nolabel=localize(30028), yeslabel=localize(30034)): + if yesno_dialog(localize(30040), localize(30033), nolabel=localize(30028), yeslabel=localize(30034), autoanswer=True): self.install_widevine() else: log('User declined to update {component}.', component=component) @@ -745,7 +746,7 @@ def _widevine_eula(self): with archive.open(config.WIDEVINE_LICENSE_FILE) as file_obj: eula = file_obj.read().decode().strip().replace('\n', ' ') - return yesno_dialog(localize(30026), eula, nolabel=localize(30028), yeslabel=localize(30027)) # Widevine CDM EULA + return yesno_dialog(localize(30026), eula, nolabel=localize(30028), yeslabel=localize(30027), autoanswer=True) # Widevine CDM EULA def _extract_widevine_from_img(self): ''' Extract the Widevine CDM binary from the mounted Chrome OS image ''' @@ -887,7 +888,7 @@ def _check_drm(self): if self._has_widevine(): return self._check_widevine() - if yesno_dialog(localize(30041), localize(30002), nolabel=localize(30028), yeslabel=localize(30038)): # Widevine required + if yesno_dialog(localize(30041), localize(30002), nolabel=localize(30028), yeslabel=localize(30038), autoanswer=True): # Widevine required return self.install_widevine() return False diff --git a/lib/inputstreamhelper/kodiutils.py b/lib/inputstreamhelper/kodiutils.py index 81542dfb..dc1ee0fc 100644 --- a/lib/inputstreamhelper/kodiutils.py +++ b/lib/inputstreamhelper/kodiutils.py @@ -49,8 +49,10 @@ def notification(heading='', message='', icon='info', time=4000): return Dialog().notification(heading=heading, message=message, icon=icon, time=time) -def ok_dialog(heading='', message=''): +def ok_dialog(heading='', message='', autoanswer=None): ''' Show Kodi's OK dialog ''' + if autoanswer is not None and get_setting('automatic_install') == 'true': + return autoanswer from xbmcgui import Dialog if not heading: heading = ADDON.getAddonInfo('name') @@ -71,8 +73,10 @@ def textviewer(heading='', text='', usemono=False): return Dialog().textviewer(heading=heading, text=text, usemono=usemono) -def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose=0): +def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose=0, autoanswer=None): ''' Show Kodi's Yes/No dialog ''' + if autoanswer is not None and get_setting('automatic_install') == 'true': + return autoanswer from xbmcgui import Dialog if not heading: heading = ADDON.getAddonInfo('name') diff --git a/resources/settings.xml b/resources/settings.xml index c40d364a..b0f16c39 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -10,6 +10,7 @@ +