Skip to content
Dag Wieers edited this page Sep 27, 2019 · 11 revisions

Integrating in your add-on

Below is an example of how to integrate InputStream Helper in your add-on.

import sys
import xbmcgui
import xbmcplugin

PROTOCOL = 'mpd'
DRM = 'com.widevine.alpha'
STREAM_URL = 'https://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel-dash-widevine.ism/.mpd'
LICENSE_URL = 'https://cwip-shaka-proxy.appspot.com/no_auth'


def play():
    from inputstreamhelper import Helper  # pylint: disable=import-outside-toplevel

    is_helper = Helper(PROTOCOL, drm=DRM)
    if is_helper.check_inputstream():
        playitem = xbmcgui.ListItem(path=STREAM_URL)
        playitem.setProperty('inputstreamaddon', is_helper.inputstream_addon)
        playitem.setProperty('inputstream.adaptive.manifest_type', PROTOCOL)
        playitem.setProperty('inputstream.adaptive.license_type', DRM)
        playitem.setProperty('inputstream.adaptive.license_key', LICENSE_URL + '||R{SSM}|')
        xbmcplugin.setResolvedUrl(handle=sys.argv[1], succeeded=True, listitem=play_item)

if __name__ == '__main__':
    play()

The Helper class takes two arguments: protocol (the media streaming protocol) and the optional argument 'drm'.

NOTE: It is recommended to not add your InputStream add-on as a dependency in addon.xml. It can cause confusion with users not being able to install your add-on because the InputStream add-on is disabled. InputStream Helper addresses issues such as these and helps the user to install/enable required InputStream components.

NOTE: Also notice that we recommend to import inputstreamhelper in the block where it will be used (contrary to general Python practices). This avoids adding to the start-up time of your add-on (especially on Raspberry Pi). This is an advice you can also use within your add-on to speed up load times.

Accepted protocol arguments:

  • mpd -- MPEG-DASH
  • ism -- Microsoft Smooth Streaming
  • hls -- HTTP Live Streaming from Apple
  • rtmp -- Real-Time Messaging Protocol

Accepted drm arguments:

  • widevine
  • com.widevine.alpha

Integrating in your add-on settings

In order to help in troubleshooting playback issues in your add-on, it could be useful to give your users direct access to the information and controls of InputStream Helper.

Typically an add-on has a special section in its settings named Troubleshooting or Expert, you could add any of the below there.

Access to Kodi/Add-on/Widevine version information

If you like you can add something like this in your resources/settings.xml.

<setting label="InputStream Helper information" type="action" id="ishelper_info" action="RunScript(script.module.inputstreamhelper,info)"/>

Access to InputStream Helper settings

If you wish to give users the ability to open the InputStream Helper directly from your settings, you can add this to your resources/settings.xml.

<setting label="InputStream Helper settings..." type="action" id="ishelper_settings" option="close" action="Addon.OpenSettings(script.module.inputstreamhelper)"/>

In this case you may want to add in gray/italic "(for protected content)" or "(for Widevine DRM content)".

Access to (re)install Widevine

If you consider it useful that the user can install or reinstall Widevine, you could add the following to your resources/settings.xml.

<setting label="(Re)install Widevine CDM..." type="action" id="install_widevine" action="RunScript(script.module.inputstreamhelper,widevine_install)" visible="!system.platform.android"/>

or to remove Widevine:

<setting label="Remove Widevine CDM..." type="action" id="remove_widevine" action="RunScript(script.module.inputstreamhelper, widevine_remove)" visible="!system.platform.android"/>
Clone this wiki locally