plugin.video.twitch icon indicating copy to clipboard operation
plugin.video.twitch copied to clipboard

Can't play stream. ERROR: EXCEPTION Thrown (PythonToCppException)

Open lorenzoPrimi opened this issue 5 years ago • 10 comments

Context

Please provide any relevant information about your setup

  • Add-on Version: 2.5.4
  • Kodi Version:18.7
  • Kodi GUI Language:English
  • Operating System:Retropie
  • Operating System Language:English

Current Behavior

I can't play the live stream, I get error all the time. Standard setup, just installed the addon, entered the key and tried to play one of the live stream in my favorites.


Log

https://paste.kodi.tv/exodebipaf.kodi


lorenzoPrimi avatar Jan 25 '21 17:01 lorenzoPrimi

I'm with the same problem, I've redone a new configuration, but it's still the same problem, what was the solution?

procobain avatar Jul 25 '21 00:07 procobain

Hi, I have the same problem

fresh instal of kodi and twitch adon + add oauth login for twitch

I can't play any live stream

Add-on Version: 2.5.11+matrix.1 Kodi Version:19.1 Kodi GUI Language:French Operating System:Windows 10 home Operating System Language:French

ERROR : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

  • NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <class 'KeyError'> Error Contents: 0 Traceback (most recent call last): File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\addon_runner.py", line 15, in router.run(sys.argv) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\router.py", line 297, in run dispatcher.dispatch(mode, queries) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\addon\common\url_dispatcher.py", line 94, in dispatch self.func_registry[mode](*args, **kwargs) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\addon\error_handling.py", line 32, in wrapper result = func(*args, **kwargs) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\router.py", line 157, in _play play.route(twitch_api, seek_time, channel_id, video_id, slug, ask, use_player, quality, channel_name) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\routes\play.py", line 117, in route videos = api.get_live(name) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\addon\error_handling.py", line 89, in wrapper result = func(*args, **kwargs) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\addon\common\cache.py", line 104, in memoizer result = func(*args, **kwargs) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\plugin.video.twitch\resources\lib\twitch_addon\addon\api.py", line 350, in get_live results = self.usher.live(name, headers=self.get_private_credential_headers()) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\script.module.python.twitch\resources\lib\twitch\parser.py", line 52, in m3u8_wrapper results = f(*args, **kwargs) File "C:\Users{userName}\AppData\Roaming\Kodi\addons\script.module.python.twitch\resources\lib\twitch\api\usher.py", line 136, in live token = token[0][keys.DATA][keys.STREAM_PLAYBACK_ACCESS_TOKEN] KeyError: 0 -->End of Python script error report<--

fennecch avatar Sep 08 '21 10:09 fennecch

I'm getting the same error, also on 2.5.11+matrix.1, but on ArchLinux.

If I can help by trying something or providing logs, let me know!

the-isz avatar Oct 01 '21 05:10 the-isz

I switched Twitch to two-factor authentication yesterday. When using the Twitch addon right after that I was asked to renew my oauth token, which I did. Right before that everything worked fine, but since then I get the exact same error.

I undid 2FA, but the error stayed.

chschnell avatar Oct 07 '21 11:10 chschnell

Did you guys enter an OAuth Token in the Private API Credentials section of the Login menu (at the very bottom)? I get this error message when I enter an incorrect token there (probably also when it expired)

Notably, it is NOT the same as the OAuth Token at the top of the same menu. See here https://github.com/anxdpanic/plugin.video.twitch/issues/461#issuecomment-552670340 how to obtain this second token from the Twitch webpage.

apo86 avatar Oct 07 '21 17:10 apo86

Did you guys enter an OAuth Token in the Private API Credentials section of the Login menu (at the very bottom)? I get this error message when I enter an incorrect token there (probably also when it expired)

Notably, it is NOT the same as the OAuth Token at the top of the same menu. See here #461 (comment) how to obtain this second token from the Twitch webpage.

Thanks for the reminder. Apparently, switching to 2FA caused my oauth-token in settings.xml ("Private API Credentials") to become invalid. I had to grab it from my twitch website cookie again, copied it into settings.xml and now everything works perfectly again as before. I'm sure if I had done that after enabling 2FA it would have fixed the issue as well.

chschnell avatar Oct 07 '21 18:10 chschnell

Did you guys enter an OAuth Token in the Private API Credentials section of the Login menu (at the very bottom)? I get this error message when I enter an incorrect token there (probably also when it expired)

Notably, it is NOT the same as the OAuth Token at the top of the same menu. See here #461 (comment) how to obtain this second token from the Twitch webpage.

Thank you, that really was the problem in my case! The whole setup is really unintuitive, though :( The process of getting the first OAuth Token is complicated enough, but the one for the Private API Credentials section? Without your help I would have never known what to do...

FYI: For who is setting this up via the config file (.kodi/userdata/addon_data/plugin.video.twitch/settings.xml):

  • The first OAuth Token goes into the oauth_token setting (remove default="true")
  • The OAuth Client ID from the Private API Credentials section (kinme78...) goes into the private_oauth_clientid setting
  • The OAuth Token from the Private API Credentials section (extracted from the website as explained here) goes into the private_oauth_token setting

Again, thanks for your help!

the-isz avatar Oct 08 '21 13:10 the-isz

I'll agree that documentation, UI and probably also error handling for this could be better (if someone has the time and is willing to do it is another story).

As for the process itself, I'm not sure it can be improved by a lot. This private OAuth token and the APIs it's used for are not part of the official Twitch API, so there's no straight forward way to obtain it. Maybe it would be possible to implement a full login feature, where you enter your username+password (+2FA) and it fetches the token for you. But I feel like this would be a significant amount of work and comes with its own set of problems (like would you actually want to give your password to the addon?)

apo86 avatar Oct 08 '21 18:10 apo86

Hi, I have exactely the same problem, i tried to change many time my token oauth but still same result :

2021-10-29 18:19:45.234 T:9009 ERROR : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<-- - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <class 'KeyError'> Error Contents: 0 Traceback (most recent call last): File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py", line 15, in router.run(sys.argv) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/router.py", line 297, in run dispatcher.dispatch(mode, queries) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/common/url_dispatcher.py", line 94, in dispatch self.func_registry[mode](*args, **kwargs) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/error_handling.py", line 32, in wrapper result = func(*args, **kwargs) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/router.py", line 157, in _play play.route(twitch_api, seek_time, channel_id, video_id, slug, ask, use_player, quality, channel_name) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/routes/play.py", line 117, in route videos = api.get_live(name) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/error_handling.py", line 89, in wrapper result = func(*args, **kwargs) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/common/cache.py", line 104, in memoizer result = func(*args, **kwargs) File "/storage/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/api.py", line 350, in get_live results = self.usher.live(name, headers=self.get_private_credential_headers()) File "/storage/.kodi/addons/script.module.python.twitch/resources/lib/twitch/parser.py", line 52, in m3u8_wrapper results = f(*args, **kwargs) File "/storage/.kodi/addons/script.module.python.twitch/resources/lib/twitch/api/usher.py", line 136, in live token = token[0][keys.DATA][keys.STREAM_PLAYBACK_ACCESS_TOKEN] KeyError: 0 -->End of Python script error report<--

rjousse18 avatar Oct 29 '21 16:10 rjousse18

https://forum.kodi.tv/showthread.php?tid=134538&pid=2919187#pid2919187 just helped me.

cobrafast avatar Nov 17 '21 02:11 cobrafast