Skip to content

Commit b05cac9

Browse files
committed
Autoinstall Widevine updates
This adds a feature to enable automatic installation of Widevine.
1 parent 9deb312 commit b05cac9

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/inputstreamhelper/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ def _install_widevine_arm(self): # pylint: disable=too-many-statements
586586
return ''
587587
required_diskspace = int(arm_device['filesize']) + int(arm_device['zipfilesize'])
588588
if yesno_dialog(localize(30001), # Due to distributing issues, this takes a long time
589-
localize(30006, diskspace=self._sizeof_fmt(required_diskspace))) and self._widevine_eula():
589+
localize(30006, diskspace=self._sizeof_fmt(required_diskspace)),
590+
autoanswer=True) and self._widevine_eula():
590591
if system_os() != 'Linux':
591592
ok_dialog(localize(30004), localize(30019, os=system_os()))
592593
return False
@@ -614,7 +615,7 @@ def _install_widevine_arm(self): # pylint: disable=too-many-statements
614615

615616
if os.getuid() != 0 and not yesno_dialog(localize(30001), # Ask for permission to run cmds as root
616617
localize(30030, cmds=', '.join(root_cmds)),
617-
nolabel=localize(30028), yeslabel=localize(30027)):
618+
nolabel=localize(30028), yeslabel=localize(30027), autoanswer=True):
618619
return False
619620

620621
# Clean up any remaining mounts
@@ -720,7 +721,7 @@ def _update_widevine(self):
720721

721722
if LooseVersion(latest_version) > LooseVersion(current_version):
722723
log('There is an update available for {component}', component=component)
723-
if yesno_dialog(localize(30040), localize(30033), nolabel=localize(30028), yeslabel=localize(30034)):
724+
if yesno_dialog(localize(30040), localize(30033), nolabel=localize(30028), yeslabel=localize(30034), autoanswer=True):
724725
self.install_widevine()
725726
else:
726727
log('User declined to update {component}.', component=component)
@@ -745,7 +746,7 @@ def _widevine_eula(self):
745746
with archive.open(config.WIDEVINE_LICENSE_FILE) as file_obj:
746747
eula = file_obj.read().decode().strip().replace('\n', ' ')
747748

748-
return yesno_dialog(localize(30026), eula, nolabel=localize(30028), yeslabel=localize(30027)) # Widevine CDM EULA
749+
return yesno_dialog(localize(30026), eula, nolabel=localize(30028), yeslabel=localize(30027), autoanswer=True) # Widevine CDM EULA
749750

750751
def _extract_widevine_from_img(self):
751752
''' Extract the Widevine CDM binary from the mounted Chrome OS image '''
@@ -887,7 +888,7 @@ def _check_drm(self):
887888
if self._has_widevine():
888889
return self._check_widevine()
889890

890-
if yesno_dialog(localize(30041), localize(30002), nolabel=localize(30028), yeslabel=localize(30038)): # Widevine required
891+
if yesno_dialog(localize(30041), localize(30002), nolabel=localize(30028), yeslabel=localize(30038), autoanswer=True): # Widevine required
891892
return self.install_widevine()
892893

893894
return False

lib/inputstreamhelper/kodiutils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ def notification(heading='', message='', icon='info', time=4000):
4949
return Dialog().notification(heading=heading, message=message, icon=icon, time=time)
5050

5151

52-
def ok_dialog(heading='', message=''):
52+
def ok_dialog(heading='', message='', autoanswer=None):
5353
''' Show Kodi's OK dialog '''
54+
if autoanswer is not None and get_setting('automatic_install') == 'true':
55+
return autoanswer
5456
from xbmcgui import Dialog
5557
if not heading:
5658
heading = ADDON.getAddonInfo('name')
@@ -71,8 +73,10 @@ def textviewer(heading='', text='', usemono=False):
7173
return Dialog().textviewer(heading=heading, text=text, usemono=usemono)
7274

7375

74-
def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose=0):
76+
def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose=0, autoanswer=None):
7577
''' Show Kodi's Yes/No dialog '''
78+
if autoanswer is not None and get_setting('automatic_install') == 'true':
79+
return autoanswer
7680
from xbmcgui import Dialog
7781
if not heading:
7882
heading = ADDON.getAddonInfo('name')

resources/settings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<setting label="30904" type="text" id="warning" enable="false"/> <!-- disabled_warning -->
1111
<setting label="30905" help="30906" type="slider" id="update_frequency" default="31" range="1,3,90" option="int" enable="eq(-2,false)" visible="!system.platform.android"/>
1212
<setting label="30907" help="30908" type="folder" id="temp_path" source="" option="writeable" default="special://masterprofile/addon_data/script.module.inputstreamhelper" visible="!system.platform.android"/>
13+
<setting label="Auto-install Widevine CDM" type="bool" id="automatic_install" default="false"/>
1314
<setting type="sep" visible="!system.platform.android"/>
1415
<setting label="30909" help="30910" type="action" id="install_widevine" action="RunScript(script.module.inputstreamhelper, widevine_install)" enable="System.HasAddon(inputstream.adaptive)" visible="!system.platform.android"/>
1516
<setting label="30911" help="30912" type="action" id="remove_widevine" action="RunScript(script.module.inputstreamhelper, widevine_remove)" enable="System.HasAddon(inputstream.adaptive)" visible="!system.platform.android"/>

0 commit comments

Comments
 (0)