Skip to content

Commit

Permalink
Autoinstall Widevine updates
Browse files Browse the repository at this point in the history
This adds a feature to enable automatic installation of Widevine.
  • Loading branch information
dagwieers committed Oct 16, 2019
1 parent e93091f commit 1f8f6f1
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/
*.py[cod]
test/cdm/
test/userdata/addon_settings.json
test/userdata/addon_data/
test/userdata/cdm/
test/userdata/tmp/

Expand Down
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ disable=
import-outside-toplevel,
line-too-long,
old-style-class,
too-many-arguments,
too-many-branches,
too-many-lines,
too-many-return-statements,
132 changes: 67 additions & 65 deletions lib/inputstreamhelper/__init__.py

Large diffs are not rendered by default.

53 changes: 51 additions & 2 deletions lib/inputstreamhelper/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
''' Implements Kodi Helper functions '''
from __future__ import absolute_import, division, unicode_literals
import xbmc
from xbmcgui import Dialog
from xbmcaddon import Addon
from .unicodehelper import from_unicode, to_unicode

Expand Down Expand Up @@ -34,6 +33,56 @@ def has_socks():
return has_socks.installed


def browsesingle(type, heading, shares='', mask='', useThumbs=False, treatAsFolder=False, defaultt=None): # pylint: disable=invalid-name,redefined-builtin
''' Show a Kodi browseSingle dialog '''
from xbmcgui import Dialog
if not heading:
heading = ADDON.getAddonInfo('name')
return Dialog().browseSingle(type=type, heading=heading, shares=shares, mask=mask, useThumbs=useThumbs, treatAsFolder=treatAsFolder, defaultt=defaultt)


def notification(heading='', message='', icon='info', time=4000):
''' Show a Kodi notification '''
from xbmcgui import Dialog
if not heading:
heading = ADDON.getAddonInfo('name')
return Dialog().notification(heading=heading, message=message, icon=icon, time=time)


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')
return Dialog().ok(heading=heading, line1=message)


def progress_dialog():
''' Show Kodi's Progress dialog '''
from xbmcgui import DialogProgress
return DialogProgress()


def textviewer(heading='', text='', usemono=False):
''' Show a Kodi textviewer dialog '''
from xbmcgui import Dialog
if not heading:
heading = ADDON.getAddonInfo('name')
return Dialog().textviewer(heading=heading, text=text, usemono=usemono)


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')
return Dialog().yesno(heading=heading, line1=message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose)


def localize(string_id, **kwargs):
''' Return the translated string from the .po language files, optionally translating variables '''
if kwargs:
Expand Down Expand Up @@ -82,7 +131,7 @@ def get_proxies():
if httpproxytype != 0 and not socks_supported:
# Only open the dialog the first time (to avoid multiple popups)
if socks_supported is None:
Dialog().ok('', localize(30042)) # Requires PySocks
ok_dialog('', localize(30042)) # Requires PySocks
return None

proxy_types = ['http', 'socks4', 'socks4a', 'socks5', 'socks5h']
Expand Down
1 change: 1 addition & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<setting label="30904" type="text" id="warning" enable="false"/> <!-- disabled_warning -->
<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"/>
<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"/>
<setting label="Auto-install Widevine CDM" type="bool" id="automatic_install" default="false"/>
<setting type="sep" visible="!system.platform.android"/>
<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"/>
<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"/>
Expand Down
2 changes: 1 addition & 1 deletion test/xbmcgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def textviewer(heading, text=None, usemono=None):
print('\033[37;44;1mTEXTVIEWER:\033[35;49;1m [%s]\n\033[37;1m%s\033[39;0m' % (heading, text))

@staticmethod
def browseSingle(type, heading, shares, mask=None, useThumbs=None, treatAsFolder=None, default=None): # pylint: disable=redefined-builtin
def browseSingle(type, heading, shares, mask=None, useThumbs=None, treatAsFolder=None, defaultt=None): # pylint: disable=redefined-builtin
''' A stub implementation for the xbmcgui Dialog class browseSingle() method '''
print('\033[37;44;1mBROWSESINGLE:\033[35;49;1m [%s] \033[37;1m%s\033[39;0m' % (type, heading))
return 'special://masterprofile/addon_data/script.module.inputstreamhelper/'
Expand Down

0 comments on commit 1f8f6f1

Please sign in to comment.