emilsvennesson / script.module.inputstreamhelper

A simple Kodi module that makes life easier for add-on developers relying on InputStream based add-ons and DRM playback.
MIT License
136 stars 49 forks source link

IndexError on demo code #272

Closed Anan5a closed 4 years ago

Anan5a commented 4 years ago

I'm trying to develop an addon to play content of a website that involves DRM So I tried the demo code from your examples. But it throws error. The demo code throws error like this

2020-02-20 18:25:56.061 T:3518   DEBUG: [script.module.inputstreamhelper]: There are no missing Widevine libraries! :-)
2020-02-20 18:25:56.061 T:3518   DEBUG: [script.module.inputstreamhelper]: Widevine update check was made on 2020-02-20T12:16:28
2020-02-20 18:25:56.073 T:3518   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'IndexError'>
                                            Error Contents: list index out of range
                                            Traceback (most recent call last):
                                              File "/home/ananta/.kodi/addons/script.addon.test/main.py", line 13, in <module>
                                                script.play()
                                              File "/home/ananta/.kodi/addons/script.addon.test/resources/lib/script.py", line 40, in play
                                                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=play_item)
                                            IndexError: list index out of range
                                            -->End of Python script error report<--
2020-02-20 18:25:56.073 T:3518   DEBUG: onExecutionDone(2, /home/ananta/.kodi/addons/script.addon.test/main.py)
2020-02-20 18:25:56.085 T:3518   DEBUG: .

I have no clue what to do now! How can I get it working?

dagwieers commented 4 years ago

The problem in your code is related to sys.argv not having any arguments apparently. I don't know what framework you are using, but you need to provide the add-on handle to setResolvedUrl().

Anan5a commented 4 years ago

@dagwieers I just copy pasted the code from docs. I used yo kodi-addon to create a skeleton addon. What should I do now?

dagwieers commented 4 years ago

You need to apply the examples to your code. Maybe look at other add-ons using inputstreamhelper. Your problem is not inputstreamhelper.

Anan5a commented 4 years ago

@dagwieers I was able to solve that problem. But now inputstreamhelper is not playing any video. Here is the relevant kodi log


2020-02-21 16:40:11.818 T:5561   DEBUG: PROTOCOL=mpd;DRM=com.widevine.alpha;STREAM_URL=https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd;LICENSE_URL=https://cwip-shaka-proxy.appspot.com/no_auth
2020-02-21 16:40:11.827 T:5503   DEBUG: ------ Window Init (DialogConfirm.xml) ------
2020-02-21 16:40:11.827 T:5503    INFO: Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY
2020-02-21 16:40:13.092 T:5503   DEBUG: ------ Window Deinit (Pointer.xml) ------
2020-02-21 16:40:13.174 T:5503   DEBUG: ProcessMouse: trying mouse action leftclick
2020-02-21 16:40:13.175 T:5503   DEBUG: ------ Window Init (Pointer.xml) ------
2020-02-21 16:40:13.438 T:5503   DEBUG: ------ Window Deinit (DialogConfirm.xml) ------
2020-02-21 16:40:13.628 T:5561   DEBUG: Handle
2020-02-21 16:40:13.628 T:5561   DEBUG: 1
2020-02-21 16:40:13.628 T:5561   DEBUG: [script.module.inputstreamhelper]: Platform information: uname_result(system='Linux', node='ananta', release='4.19.0-8-amd64', version='#1 SMP Debian 4.19.98-1 (2020-01-26)', machine='x86_64', processor='')
2020-02-21 16:40:13.628 T:5561   DEBUG: [script.module.inputstreamhelper]: jsonrpc payload: {'jsonrpc': '2.0', 'id': 1, 'method': 'Settings.GetSettingValue', 'params': {'setting': 'network.usehttpproxy'}}
2020-02-21 16:40:13.628 T:5561   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "Settings.GetSettingValue", "params": {"setting": "network.usehttpproxy"}}
2020-02-21 16:40:13.628 T:5561   DEBUG: [script.module.inputstreamhelper]: jsonrpc response: {"id":1,"jsonrpc":"2.0","result":{"value":false}}
2020-02-21 16:40:13.629 T:5561   DEBUG: CAddonSettings[script.module.inputstreamhelper]: loading setting definitions
2020-02-21 16:40:13.629 T:5561   DEBUG: CAddonSettings[script.module.inputstreamhelper]: trying to load setting definitions from old format...
2020-02-21 16:40:13.629 T:5561   DEBUG: CAddonSettings[script.module.inputstreamhelper]: loading setting values
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: jsonrpc payload: {'jsonrpc': '2.0', 'id': 1, 'method': 'Addons.GetAddonDetails', 'params': {'addonid': 'inputstream.adaptive'}}
2020-02-21 16:40:13.639 T:5561   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddonDetails", "params": {"addonid": "inputstream.adaptive"}}
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: jsonrpc response: {"id":1,"jsonrpc":"2.0","result":{"addon":{"addonid":"inputstream.adaptive","type":"kodi.inputstream"}}}
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: inputstream.adaptive is installed.
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: jsonrpc payload: {'jsonrpc': '2.0', 'id': 1, 'method': 'Addons.GetAddonDetails', 'params': {'addonid': 'inputstream.adaptive', 'properties': ['enabled']}}
2020-02-21 16:40:13.639 T:5561   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddonDetails", "params": {"addonid": "inputstream.adaptive", "properties": ["enabled"]}}
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: jsonrpc response: {"id":1,"jsonrpc":"2.0","result":{"addon":{"addonid":"inputstream.adaptive","enabled":true,"type":"kodi.inputstream"}}}
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: inputstream.adaptive 2.4.0 is enabled.
2020-02-21 16:40:13.639 T:5561   DEBUG: [script.module.inputstreamhelper]: inputstream.adaptive 2.4.0 is installed and enabled.
2020-02-21 16:40:13.639 T:5561   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:13.641 T:5561   DEBUG: Previous line repeats 3 times.
2020-02-21 16:40:13.641 T:5561   DEBUG: [script.module.inputstreamhelper]: Found Widevine binary at /home/ananta/.kodi/cdm/libwidevinecdm.so
2020-02-21 16:40:13.641 T:5561   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:13.670 T:5561   DEBUG: Previous line repeats 5 times.
2020-02-21 16:40:13.670 T:5561   DEBUG: [script.module.inputstreamhelper]: ['ldd', '/home/ananta/.kodi/cdm/libwidevinecdm.so'] cmd executed successfully.
2020-02-21 16:40:13.670 T:5561   DEBUG: [script.module.inputstreamhelper]: ['ldd', '/home/ananta/.kodi/cdm/libwidevinecdm.so'] cmd output:
                                            b'\tlinux-vdso.so.1 (0x00007ffdba1aa000)\n\tlibpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4cb8b3f000)\n\tlibm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4cb89bc000)\n\tlibdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4cb89b7000)\n\tlibrt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f4cb89ad000)\n\tlibglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f4cb888e000)\n\tlibnss3.so => /lib/x86_64-linux-gnu/libnss3.so (0x00007f4cb8740000)\n\tlibnssutil3.so => /lib/x86_64-linux-gnu/libnssutil3.so (0x00007f4cb870c000)\n\tlibnspr4.so => /lib/x86_64-linux-gnu/libnspr4.so (0x00007f4cb86cb000)\n\tlibgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4cb86b1000)\n\tlibc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4cb84f0000)\n\t/lib64/ld-linux-x86-64.so.2 (0x00007f4cb945f000)\n\tlibpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f4cb847c000)\n\tlibplc4.so => /lib/x86_64-linux-gnu/libplc4.so (0x00007f4cb8475000)\n\tlibplds4.so => /lib/x86_64-linux-gnu/libplds4.so (0x00007f4cb846e000)\n'
2020-02-21 16:40:13.670 T:5561   DEBUG: [script.module.inputstreamhelper]: There are no missing Widevine libraries! :-)
2020-02-21 16:40:13.670 T:5561   DEBUG: [script.module.inputstreamhelper]: Widevine update check was made on 2020-02-20T12:16:28
2020-02-21 16:40:13.670 T:5561   DEBUG: Inside play condition...
2020-02-21 16:40:13.672 T:5561   DEBUG: False
2020-02-21 16:40:13.672 T:5560   DEBUG: Thread waiting 139739369826048 terminating
2020-02-21 16:40:13.688 T:5503   DEBUG: ------ Window Deinit (DialogBusy.xml) ------
2020-02-21 16:40:13.690 T:5573   DEBUG: Thread BackgroundLoader start, auto delete: false
2020-02-21 16:40:13.693 T:5573   DEBUG: Thread BackgroundLoader 139739369826048 terminating
2020-02-21 16:40:14.671 T:5561   DEBUG: Trying default player...
2020-02-21 16:40:14.672 T:5561    INFO: CPythonInvoker(2, /home/ananta/.kodi/addons/script.widevine.test-plugin/main.py): script successfully run
2020-02-21 16:40:14.672 T:5561   DEBUG: onExecutionDone(2, /home/ananta/.kodi/addons/script.widevine.test-plugin/main.py)
2020-02-21 16:40:14.692 T:5561   DEBUG: .
2020-02-21 16:40:14.718 T:5561 WARNING: CPythonInvoker(2, /home/ananta/.kodi/addons/script.widevine.test-plugin/main.py): the python script "/home/ananta/.kodi/addons/script.widevine.test-plugin/main.py" has left several classes in memory that we couldn't clean up. The classes include: N9XBMCAddon9xbmcaddon5AddonE
2020-02-21 16:40:14.718 T:5561    INFO: Python interpreter stopped
2020-02-21 16:40:14.718 T:5561   DEBUG: Thread LanguageInvoker 139739965413120 terminating
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerCoreFactory::GetPlayers(https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd)
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: system rules
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: matches rule: system rules
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: mms/udp
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: lastfm/shout
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: rtmp
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: rtsp
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: streams
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: matches rule: streams
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: aacp/sdp
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: mp2
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: dvd
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: discimage
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: sdp/asf
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: nsv
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: radio
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerCoreFactory::GetPlayers: matched 0 rules with players
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerCoreFactory::GetPlayers: adding videodefaultplayer (VideoPlayer)
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerCoreFactory::GetPlayers: for video=1, audio=0
2020-02-21 16:40:15.487 T:5503   DEBUG: CPlayerCoreFactory::GetPlayers: for video=1, audio=1
2020-02-21 16:40:15.488 T:5503   DEBUG: CPlayerCoreFactory::GetPlayers: added 1 players
2020-02-21 16:40:15.509 T:5503   DEBUG: Radio UECP (RDS) Processor - new CDVDRadioRDSData
2020-02-21 16:40:15.509 T:5503  NOTICE: VideoPlayer::OpenFile: https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd
2020-02-21 16:40:15.509 T:5574   DEBUG: Thread VideoPlayer start, auto delete: false
2020-02-21 16:40:15.509 T:5503   DEBUG: OnPlayBackStarted: CApplication::OnPlayBackStarted
2020-02-21 16:40:15.509 T:5574  NOTICE: Creating InputStream
2020-02-21 16:40:15.509 T:5574   DEBUG: ADDON: Dll Initializing - InputStream Adaptive
2020-02-21 16:40:15.509 T:5574   DEBUG: SECTION:LoadDLL(/usr/local/lib/kodi/addons/inputstream.adaptive/inputstream.adaptive.so.2.4.0)
2020-02-21 16:40:15.509 T:5574   DEBUG: Loading: /usr/local/lib/kodi/addons/inputstream.adaptive/inputstream.adaptive.so.2.4.0
2020-02-21 16:40:15.511 T:5519   DEBUG: Loading settings for https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd
2020-02-21 16:40:15.513 T:5503   DEBUG: CVideoGUIInfo::InitCurrentItem(https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd)
2020-02-21 16:40:15.517 T:5503   DEBUG: CPlayerGUIInfo::InitCurrentItem(https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd)
2020-02-21 16:40:15.517 T:5504   DEBUG: CAnnouncementManager - Announcement: OnChanged from xbmc
2020-02-21 16:40:15.517 T:5504   DEBUG: GOT ANNOUNCEMENT, type: 1024, from xbmc, message OnChanged
2020-02-21 16:40:15.519 T:5504   DEBUG: CAnnouncementManager - Announcement: OnPlay from xbmc
2020-02-21 16:40:15.519 T:5504   DEBUG: GOT ANNOUNCEMENT, type: 1, from xbmc, message OnPlay
2020-02-21 16:40:15.574 T:5574    INFO: AddOnLog: InputStream Adaptive: SetVideoResolution (720 x 480)
2020-02-21 16:40:15.574 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Open()
2020-02-21 16:40:15.574 T:5574   DEBUG: AddOnLog: InputStream Adaptive: found inputstream.adaptive.license_key: [not shown]
2020-02-21 16:40:15.574 T:5574   DEBUG: AddOnLog: InputStream Adaptive: found inputstream.adaptive.license_type: com.widevine.alpha
2020-02-21 16:40:15.574 T:5574   DEBUG: AddOnLog: InputStream Adaptive: found inputstream.adaptive.manifest_type: mpd
2020-02-21 16:40:15.574 T:5574   DEBUG: AddOnLog: InputStream Adaptive: found inputstream.adaptive.max_bandwidth: 1215752192
2020-02-21 16:40:15.575 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Initial bandwidth: 4000000
2020-02-21 16:40:15.575 T:5574   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:15.575 T:5574   DEBUG: AddOnLog: InputStream Adaptive: MAXRESOLUTION selected: 0
2020-02-21 16:40:15.576 T:5574   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:15.576 T:5574   DEBUG: AddOnLog: InputStream Adaptive: MAXRESOLUTIONSECURE selected: 0
2020-02-21 16:40:15.576 T:5574   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:15.576 T:5574   DEBUG: AddOnLog: InputStream Adaptive: STREAMSELECTION selected: 0
2020-02-21 16:40:15.576 T:5574   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:15.577 T:5574   DEBUG: Previous line repeats 3 times.
2020-02-21 16:40:15.577 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Searching for decrypters in: /usr/local/lib/kodi/addons/inputstream.adaptive/
2020-02-21 16:40:15.617 T:5503   DEBUG: ------ Window Init (DialogBusy.xml) ------
2020-02-21 16:40:15.642 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Found decrypter: /usr/local/lib/kodi/addons/inputstream.adaptive/libssd_wv.so
2020-02-21 16:40:15.642 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Supported URN: urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED
2020-02-21 16:40:15.642 T:5574   DEBUG: CurlFile::Open(0x7f178c00fb20) https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd
2020-02-21 16:40:15.642 T:5574    INFO: easy_acquire - Created session to https://storage.googleapis.com
2020-02-21 16:40:15.642 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 0 ms for 6 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.642 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 30000 ms for 2 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.642 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.642 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 0 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.742 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 2 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.742 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 50 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.843 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:15.843 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 4 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.843 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 50 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.943 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:15.943 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 8 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.943 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:15.948 T:5503   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:15.948 T:5503   DEBUG: ------ Window Deinit (DialogNotification.xml) ------
2020-02-21 16:40:16.043 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 16 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.043 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.144 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:16.144 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 32 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.144 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.244 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:16.244 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 64 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.244 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.344 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:16.344 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 128 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.345 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.445 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:16.445 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 128 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.445 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.545 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:16.545 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 128 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.545 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 1 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.645 T:5574   DEBUG: Previous line repeats 2 times.
2020-02-21 16:40:16.645 T:5574   DEBUG: Curl::Debug - TEXT:   Trying 216.58.200.144...
2020-02-21 16:40:16.645 T:5574   DEBUG: Curl::Debug - TEXT: TCP_NODELAY set
2020-02-21 16:40:16.645 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 14498 ms for 3 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.646 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 4 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.846 T:5574   DEBUG: Curl::Debug - TEXT:   Trying 2404:6800:4007:808::2010...
2020-02-21 16:40:16.846 T:5574   DEBUG: Curl::Debug - TEXT: TCP_NODELAY set
2020-02-21 16:40:16.846 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 14498 ms for 3 (transfer 0x7f178c1030a0)
2020-02-21 16:40:16.846 T:5574   DEBUG: Curl::Debug - TEXT: Immediate connect fail for 2404:6800:4007:808::2010: Network is unreachable
2020-02-21 16:40:17.158 T:5574   DEBUG: Curl::Debug - TEXT: Connected to storage.googleapis.com (216.58.200.144) port 443 (#0)
2020-02-21 16:40:17.315 T:5574   DEBUG: Curl::Debug - TEXT: found 386 certificates in /etc/ssl/certs
2020-02-21 16:40:17.315 T:5574   DEBUG: Curl::Debug - TEXT: ALPN, offering h2
2020-02-21 16:40:17.315 T:5574   DEBUG: Curl::Debug - TEXT: ALPN, offering http/1.1
2020-02-21 16:40:19.548 T:5574   DEBUG: Curl::Debug - TEXT: SSL connection using TLS1.2 / ECDHE_ECDSA_CHACHA20_POLY1305
2020-02-21 16:40:19.913 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate verification OK
2020-02-21 16:40:19.913 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate status verification SKIPPED
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      common name: *.storage.googleapis.com (matched)
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate expiration date OK
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate activation date OK
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      certificate public key: EC/ECDSA
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      certificate version: #3
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      subject: C=US,ST=California,L=Mountain View,O=Google LLC,CN=*.storage.googleapis.com
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      start date: Wed, 29 Jan 2020 21:59:39 GMT
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      expire date: Wed, 22 Apr 2020 21:59:39 GMT
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      issuer: C=US,O=Google Trust Services,CN=GTS CA 1O1
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT:      compression: NULL
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: ALPN, server accepted to use h2
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: Using HTTP2, server supports multi-use
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: Connection state changed (HTTP/2 confirmed)
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: Using Stream ID: 1 (easy handle 0x7f178c1030a0)
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - HEADER_OUT: GET /shaka-demo-assets/sintel-widevine/dash.mpd HTTP/2
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Host: storage.googleapis.com
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - HEADER_OUT: User-Agent: Kodi/19.0-ALPHA1 (X11; Linux x86_64) Debian GNU/Linux/10 App_Bitness/64 Version/19.0-ALPHA1-Git:20200219-0275416dcd
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Accept: */*
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Accept-Encoding: gzip
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Accept-Charset: UTF-8,*;q=0.8
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
2020-02-21 16:40:19.914 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1000 ms for 7 (transfer 0x7f178c1030a0)
2020-02-21 16:40:20.343 T:5574   DEBUG: Previous line repeats 2 times.
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: HTTP/2 200
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-guploader-uploadid: AEnB2UpYKrBIbl4vuvtU3sbUbgi7ivUPH3z8wD_bwCz4iPrCbRm8gwphJcZHUUI9VZFWPd6i_y46FC1-3XTMMumh1WkKR6Ss3A
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: expires: Fri, 21 Feb 2020 11:40:20 GMT
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: date: Fri, 21 Feb 2020 10:40:20 GMT
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: cache-control: public, max-age=3600
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: last-modified: Wed, 13 Sep 2017 21:02:11 GMT
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: etag: "e0330bd770d6b6f10b0706e6bd6696fb"
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-generation: 1505336531190943
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-metageneration: 1
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-stored-content-encoding: identity
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-stored-content-length: 15765
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: content-type: application/octet-stream
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: content-language: en
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-hash: crc32c=76uNBw==
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-hash: md5=4DML13DWtvELBwbmvWaW+w==
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-goog-storage-class: MULTI_REGIONAL
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: accept-ranges: bytes
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: content-length: 15765
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: access-control-allow-origin: *
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: access-control-expose-headers: If-Modified-Since
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: access-control-expose-headers: Range
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: access-control-expose-headers: Origin
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: server: UploadServer
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - HEADER_IN: alt-svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
2020-02-21 16:40:20.343 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1000 ms for 7 (transfer 0x7f178c1030a0)
2020-02-21 16:40:20.361 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:20.361 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Effective URL https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd
2020-02-21 16:40:20.362 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1000 ms for 7 (transfer 0x7f178c1030a0)
2020-02-21 16:40:20.392 T:5574   DEBUG: Previous line repeats 9 times.
2020-02-21 16:40:20.392 T:5574   DEBUG: Curl::Debug - TEXT: Connection #0 to host storage.googleapis.com left intact
2020-02-21 16:40:20.397 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Download https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd finished
2020-02-21 16:40:20.398 T:5574    INFO: AddOnLog: InputStream Adaptive: Successfully parsed .mpd file. #Periods: 1, #Streams in first period: 18, Type: VOD, Download speed: 0.0000 Bytes/s
2020-02-21 16:40:20.399 T:5574   DEBUG: CAddonSettings[inputstream.adaptive]: loading setting definitions
2020-02-21 16:40:20.400 T:5574   DEBUG: Previous line repeats 1 times.
2020-02-21 16:40:20.400 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Entering encryption section
2020-02-21 16:40:20.490 T:5574   DEBUG: AddOnLog: InputStream Adaptive: CDM version: 4.10.1582.1
2020-02-21 16:40:20.584 T:5574   DEBUG: AddOnLog: InputStream Adaptive: cdm::OnInitialized: true
2020-02-21 16:40:20.598 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Initializing stream with KID: 517453862D4256FD8BAD4F58422004D7
2020-02-21 16:40:20.655 T:5574   DEBUG: AddOnLog: InputStream Adaptive: CDMMessage: 1 arrived!
2020-02-21 16:40:20.655 T:5574   DEBUG: CurlFile::ParseAndCorrectUrl() adding custom header option 'Content-Type: application/x-www-form-urlencoded'
2020-02-21 16:40:20.655 T:5574   DEBUG: CurlFile::ParseAndCorrectUrl() adding custom header option 'Expect: '
2020-02-21 16:40:20.655 T:5574   DEBUG: CurlFile::Open(0x7f178c00fb20) https://cwip-shaka-proxy.appspot.com/no_auth
2020-02-21 16:40:20.655 T:5574    INFO: easy_acquire - Created session to https://cwip-shaka-proxy.appspot.com
2020-02-21 16:40:20.655 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 0 ms for 6 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.655 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 30000 ms for 2 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.655 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1 ms for 1 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.656 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 0 ms for 1 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.756 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 2 ms for 1 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.756 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 50 ms for 1 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.856 T:5574   DEBUG: Previous line repeats 2 times.
2020-02-21 16:40:20.856 T:5574   DEBUG: Curl::Debug - TEXT:   Trying 172.217.163.52...
2020-02-21 16:40:20.856 T:5574   DEBUG: Curl::Debug - TEXT: TCP_NODELAY set
2020-02-21 16:40:20.856 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 14900 ms for 3 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.856 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 200 ms for 4 (transfer 0x7f178c0e2520)
2020-02-21 16:40:20.958 T:5574   DEBUG: Curl::Debug - TEXT: Connected to cwip-shaka-proxy.appspot.com (172.217.163.52) port 443 (#0)
2020-02-21 16:40:20.991 T:5574   DEBUG: Curl::Debug - TEXT: found 386 certificates in /etc/ssl/certs
2020-02-21 16:40:20.991 T:5574   DEBUG: Curl::Debug - TEXT: ALPN, offering h2
2020-02-21 16:40:20.991 T:5574   DEBUG: Curl::Debug - TEXT: ALPN, offering http/1.1
2020-02-21 16:40:21.309 T:5574   DEBUG: Curl::Debug - TEXT: SSL connection using TLS1.2 / ECDHE_RSA_CHACHA20_POLY1305
2020-02-21 16:40:21.310 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate verification OK
2020-02-21 16:40:21.310 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate status verification SKIPPED
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      common name: *.appspot.com (matched)
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate expiration date OK
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      server certificate activation date OK
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      certificate public key: RSA
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      certificate version: #3
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      subject: C=US,ST=California,L=Mountain View,O=Google LLC,CN=*.appspot.com
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      start date: Wed, 29 Jan 2020 21:52:39 GMT
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      expire date: Wed, 22 Apr 2020 21:52:39 GMT
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      issuer: C=US,O=Google Trust Services,CN=GTS CA 1O1
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT:      compression: NULL
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: ALPN, server accepted to use h2
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: Using HTTP2, server supports multi-use
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: Connection state changed (HTTP/2 confirmed)
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: Using Stream ID: 1 (easy handle 0x7f178c0e2520)
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: POST /no_auth HTTP/2
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Host: cwip-shaka-proxy.appspot.com
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: User-Agent: Kodi/19.0-ALPHA1 (X11; Linux x86_64) Debian GNU/Linux/10 App_Bitness/64 Version/19.0-ALPHA1-Git:20200219-0275416dcd
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Accept: */*
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Accept-Encoding: gzip, deflate
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Accept-Charset: UTF-8,*;q=0.8
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Content-Type: application/x-www-form-urlencoded
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - HEADER_OUT: Content-Length: 2648
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: We are completely uploaded and fine
2020-02-21 16:40:21.311 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1000 ms for 7 (transfer 0x7f178c0e2520)
2020-02-21 16:40:21.837 T:5574   DEBUG: Previous line repeats 2 times.
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: HTTP/2 500
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: content-type: text/html; charset=utf-8
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: cache-control: no-cache
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: access-control-allow-origin: *
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: x-cloud-trace-context: ed771fd78fe9d9d837b9b908a52f96a9;o=1
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: date: Fri, 21 Feb 2020 10:40:21 GMT
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: server: Google Frontend
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: content-length: 25
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - HEADER_IN: alt-svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - TEXT: Expire in 1000 ms for 7 (transfer 0x7f178c0e2520)
2020-02-21 16:40:21.837 T:5574   DEBUG: Curl::Debug - TEXT: Connection #0 to host cwip-shaka-proxy.appspot.com left intact
2020-02-21 16:40:21.837 T:5574   ERROR: CCurlFile::Open failed with code 500 for https://cwip-shaka-proxy.appspot.com/no_auth:
                                            INVALID_LICENSE_CHALLENGE
2020-02-21 16:40:21.837 T:5574   ERROR: AddOnLog: InputStream Adaptive: License server returned failure
2020-02-21 16:40:21.838 T:5574   ERROR: AddOnLog: InputStream Adaptive: License update not successful (no keys)
2020-02-21 16:40:21.838 T:5574   DEBUG: AddOnLog: InputStream Adaptive: CDMMessage: 4 arrived!
2020-02-21 16:40:21.838 T:5574   ERROR: AddOnLog: InputStream Adaptive: Initialize failed (SingleSampleDecrypter)
2020-02-21 16:40:21.838 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Session::~Session()
2020-02-21 16:40:21.841 T:5574   ERROR: CVideoPlayer::OpenInputStream - error opening [https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd]
2020-02-21 16:40:21.841 T:5574  NOTICE: CVideoPlayer::OnExit()
2020-02-21 16:40:21.841 T:5574   DEBUG: AddOnLog: InputStream Adaptive: Close()
2020-02-21 16:40:21.841 T:5574   DEBUG: SECTION:UnloadDll(/usr/local/lib/kodi/addons/inputstream.adaptive/inputstream.adaptive.so.2.4.0)
2020-02-21 16:40:21.841 T:5574    INFO: ADDON: Dll Destroyed - InputStream Adaptive
2020-02-21 16:40:21.841 T:5574   DEBUG: Thread VideoPlayer 139739359016704 terminating
2020-02-21 16:40:21.844 T:5516   DEBUG: OnPlayBackStopped: CApplication::OnPlayBackStopped
2020-02-21 16:40:21.846 T:5504   DEBUG: CAnnouncementManager - Announcement: OnStop from xbmc
2020-02-21 16:40:21.846 T:5504   DEBUG: GOT ANNOUNCEMENT, type: 1, from xbmc, message OnStop
2020-02-21 16:40:21.850 T:5503   DEBUG: ------ Window Init (DialogConfirm.xml) ------
2020-02-21 16:40:21.851 T:5503   DEBUG: ffmpeg[(nil)X]: [swscaler] Forcing full internal H chroma due to input having non subsampled chroma
2020-02-21 16:40:21.852 T:5503  NOTICE: CVideoPlayer::CloseFile()
2020-02-21 16:40:21.852 T:5503   DEBUG: DeleteRenderer - deleting renderer
2020-02-21 16:40:21.852 T:5503   DEBUG: LinuxRendererGL: Cleaning up GL resources
2020-02-21 16:40:21.852 T:5503  NOTICE: VideoPlayer: waiting for threads to exit
2020-02-21 16:40:21.852 T:5503  NOTICE: VideoPlayer: finished waiting
2020-02-21 16:40:21.853 T:5503   DEBUG: Radio UECP (RDS) Processor - delete ~CDVDRadioRDSData

The xbmcplugin.setResolvedUrl seems do nothing. When I triggered xbmc.Player().play(...) It produced the above log. Don't really understand where should I post it, inputstream.adaptive or here.

dagwieers commented 4 years ago

inputstreamhelper doesn't play videos, it only takes care of ensuring you have the necessary inputstream add-on and Widevine CDM library for playback. Most likely your problem is not inputstream.adaptive but a coding error, so you should turn to the Kodi forums and ask other add-on developers to help you.

The logs may not be useful if you make a programming mistake, the code is essential.

Anan5a commented 4 years ago

I have posted in kodi forum. Thank you

Here is the code BTW

# -*- coding: utf-8 -*-

from resources.lib import kodiutils
import logging
import xbmcaddon
import xbmcgui
import xbmc
import xbmcplugin

ADDON = xbmcaddon.Addon()
logger = logging.getLogger(ADDON.getAddonInfo('id'))

# Put your code here, this is just an example showing
# a textbox as soon as this addon gets called
def show_dialog():
    addon_name = ADDON.getAddonInfo('name')

    line1 = "Hello World!"

    xbmcgui.Dialog().ok(addon_name, line1)

PROTOCOL = 'mpd'
DRM = 'com.widevine.alpha'
STREAM_URL = 'https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd'
LICENSE_URL = 'https://cwip-shaka-proxy.appspot.com/no_auth'

xbmc.log('PROTOCOL='+PROTOCOL+';DRM='+DRM+';STREAM_URL='+STREAM_URL+';LICENSE_URL='+LICENSE_URL)

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

    xbmc.log('Handle')
    print(handle)

    is_helper = Helper(PROTOCOL, drm=DRM)
    if is_helper.check_inputstream():
        xbmc.log('Inside play condition...')
        play_item = xbmcgui.ListItem(path=STREAM_URL)
        play_item.setProperty('inputstreamaddon', is_helper.inputstream_addon)
        play_item.setProperty('inputstream.adaptive.manifest_type', PROTOCOL)
        play_item.setProperty('inputstream.adaptive.license_type', DRM)
        play_item.setProperty('inputstream.adaptive.license_key', LICENSE_URL)
        play_item.setProperty('IsPlayable', 'true')
        play_item.setMimeType('application/dash+xml')
        play_item.setContentLookup(False)
        play_item.setProperty('inputstream.adaptive.max_bandwidth', str(100000000000))
        play_item.setProperty('network.bandwidth', str(100000000000))

        xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=play_item)

        print(xbmc.Player().isPlaying())
        xbmc.sleep(1000);
        if not xbmc.Player().isPlaying():
            xbmc.log('Trying default player...')
            xbmc.Player().play(item=STREAM_URL, listitem=play_item);