anxdpanic / plugin.video.twitch

Watch your favorite gaming streams on Kodi
https://twitchaddon.page.link/forum
266 stars 81 forks source link

Error 401 when playing any video (stream or replay) #636

Closed nitramm closed 2 years ago

nitramm commented 2 years ago

Context

My version setup


Expected Behavior

Hi, the issue happens since a couple of weeks when I just try to play a video (stream or replay). My OAuth token seems to be valid cause I can browse the channels I've subscribed.


Current Behavior

Kodi raise an error.


Log

2022-02-18 19:49:43.440 T:2771    DEBUG <general>: CLibInputKeyboard::ProcessKey - using delay: 500ms repeat: 50ms
2022-02-18 19:49:43.441 T:4158    DEBUG <general>: Thread Timer start, auto delete: false
2022-02-18 19:49:43.448 T:2666    DEBUG <general>: Keyboard: scancode: 0x1c, sym: 0x13, unicode: 0x000d, modifier: 0x0
2022-02-18 19:49:43.561 T:4158    DEBUG <general>: Thread Timer 3942318272 terminating
2022-02-18 19:49:43.582 T:2666    DEBUG <general>: Keyboard: scancode: 0x1c, sym: 0x13, unicode: 0x000d, modifier: 0x0
2022-02-18 19:49:43.582 T:2666    DEBUG <general>: HandleKey: return (0xf00d) pressed, action is Select
2022-02-18 19:49:43.592 T:2666    DEBUG <general>: StartScript - calling plugin Twitch('plugin://plugin.video.twitch/','2','?mode=play&channel_id=758313841','resume:false')
2022-02-18 19:49:43.592 T:2666    DEBUG <general>: GetLanguageInvoker - Reusing LanguageInvokerThread 13 for script /home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py
2022-02-18 19:49:43.593 T:4116     INFO <general>: initializing python engine.
2022-02-18 19:49:43.593 T:4116    DEBUG <general>: CPythonInvoker(13, /home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py): start processing
2022-02-18 19:49:43.593 T:4116    DEBUG <general>: CPythonInvoker(13, /home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py): entering source directory /home/osmc/.kodi/addons/plugin.video.twitch/resources/lib
2022-02-18 19:49:43.593 T:4116    DEBUG <general>: CPythonInvoker(13, /home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py): instantiating addon using automatically obtained id of "plugin.video.twitch" dependent on version 3.0.0 of the xbmc.python api
2022-02-18 19:49:43.594 T:4116    DEBUG <general>: JSONRPC: Incoming request: {"jsonrpc": "2.0", "method": "Application.GetProperties", "params": {"properties": ["name"]}, "id": 1}
2022-02-18 19:49:43.595 T:4116    DEBUG <general>: Twitch: Version: |2.5.12+matrix.1| Application Version: |Kodi| |19.3| -> |19|3||0||
2022-02-18 19:49:43.595 T:4116    DEBUG <general>: Twitch: Queries: |{'mode': 'play', 'channel_id': '758313841'}| Args: |['plugin://plugin.video.twitch/', '2', '?mode=play&channel_id=758313841', 'resume:false']|
2022-02-18 19:49:43.596 T:4116    DEBUG <general>: Twitch: Using method cache for: |twitch_addon.addon.api.Twitch.valid_token| -> |4|
2022-02-18 19:49:43.596 T:4116     INFO <general>: Twitch: Calling |_play| for mode |play| with pos args |[]| and kwargs |{'channel_id': '758313841'}|
2022-02-18 19:49:43.599 T:4116    DEBUG <general>: Twitch: Calling cached method: |twitch_addon.addon.api.Twitch.get_channel_stream|
2022-02-18 19:49:43.600 T:4116    DEBUG <general>: script.module.python.twitch: GET QUERY: url: |https://api.twitch.tv/kraken/streams|, params: |{'channel': '758313841', 'stream_type': 'all'}|, data: |{}|, headers: |{'ACCEPT': 'application/vnd.twitchtv.v5+json', 'Client-ID': 'ps2ed9zlj8zyqztsdz2tl4uys84b8k'}|, target_func: |by_id|
2022-02-18 19:49:43.600 T:4116    DEBUG <general>: script.module.python.twitch: Downloading: |https://api.twitch.tv/kraken/streams?channel=758313841&stream_type=all|
2022-02-18 19:49:43.613 T:4159    DEBUG <general>: Thread scriptobs start, auto delete: false
2022-02-18 19:49:43.813 T:2666    DEBUG <general>: ------ Window Init (DialogBusy.xml) ------
2022-02-18 19:49:43.902 T:4116    DEBUG <general>: script.module.python.twitch: url: |https://api.twitch.tv/kraken/streams| parameters: |{'channel': '758313841', 'stream_type': 'all'}|
                                                   {
                                                       "streams": [
                                                           {
                                                               "_id": 44740390188,
                                                               "average_fps": 30,
                                                               "broadcast_platform": "live",
                                                               "channel": {
                                                                   "_id": 758313841,
                                                                   "broadcaster_language": "fr",
                                                                   "broadcaster_software": "",
                                                                   "broadcaster_type": "",
                                                                   "created_at": "2022-01-03T13:44:26.639714Z",
                                                                   "description": "Salut \u00e0 tous et bienvenue sur ma chaine Twitch. Ici on joue, on fait de la musique et on regarde des images du pass\u00e9. ",
                                                                   "display_name": "Gilles_Stella",
                                                                   "followers": 3171,
                                                                   "game": "Retro",
                                                                   "language": "fr",
                                                                   "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/9466ea89-fc3c-4e57-ad35-e93fa1e44cf1-profile_image-300x300.png",
                                                                   "mature": false,
                                                                   "name": "gilles_stella",
                                                                   "partner": false,
                                                                   "privacy_options_enabled": false,
                                                                   "private_video": false,
                                                                   "profile_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/6d02afd7-6837-4dd0-ae4e-d11ec6496ff8-profile_banner-480.png",
                                                                   "profile_banner_background_color": "",
                                                                   "status": "On discute un peu puis on continue Landstalker !",
                                                                   "updated_at": "2022-02-18T18:29:37.471559Z",
                                                                   "url": "https://www.twitch.tv/gilles_stella",
                                                                   "video_banner": null,
                                                                   "views": 6304
                                                               },
                                                               "community_id": "",
                                                               "community_ids": [],
                                                               "created_at": "2022-02-18T17:18:03Z",
                                                               "delay": 0,
                                                               "game": "Retro",
                                                               "is_playlist": false,
                                                               "preview": {
                                                                   "large": "https://static-cdn.jtvnw.net/previews-ttv/live_user_gilles_stella-640x360.jpg",
                                                                   "medium": "https://static-cdn.jtvnw.net/previews-ttv/live_user_gilles_stella-320x180.jpg",
                                                                   "small": "https://static-cdn.jtvnw.net/previews-ttv/live_user_gilles_stella-80x45.jpg",
                                                                   "template": "https://static-cdn.jtvnw.net/previews-ttv/live_user_gilles_stella-{width}x{height}.jpg"
                                                               },
                                                               "stream_type": "live",
                                                               "video_height": 1080,
                                                               "viewers": 188
                                                           }
                                                       ]
                                                   }
2022-02-18 19:49:43.904 T:4116    DEBUG <general>: Twitch: Calling cached method: |twitch_addon.addon.api.Twitch.get_live|
2022-02-18 19:49:43.905 T:4116    DEBUG <general>: script.module.python.twitch: POST QUERY: url: |https://gql.twitch.tv/gql|, params: |{}|, data: |[{'operationName': 'PlaybackAccessToken_Template', 'query': 'query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) {  streamPlaybackAccessToken(channelName: $login, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isLive) {    value    signature    __typename  }  videoPlaybackAccessToken(id: $vodID, params: {platform: "web", playerBackend: "mediaplayer", playerType: $playerType}) @include(if: $isVod) {    value    signature    __typename  }}', 'variables': {'isLive': True, 'login': 'gilles_stella', 'isVod': False, 'vodID': '', 'playerType': 'site'}}]|, headers: |{'Client-ID': '', 'Authorization': 'OAuth ***********'}|, target_func: |channel_token|
2022-02-18 19:49:43.906 T:4116    DEBUG <general>: script.module.python.twitch: Downloading: |https://gql.twitch.tv/gql|
2022-02-18 19:49:44.198 T:4116    DEBUG <general>: script.module.python.twitch: url: |https://gql.twitch.tv/gql| parameters: |{}|
                                                   {
                                                       "error": "Unauthorized",
                                                       "message": "The \"Authorization\" token is invalid.",
                                                       "status": 401
                                                   }
2022-02-18 19:49:44.206 T:4116    ERROR <general>: 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 "/home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/addon_runner.py", line 15, in <module>
                                                       router.run(sys.argv)
                                                     File "/home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/router.py", line 297, in run
                                                       dispatcher.dispatch(mode, queries)
                                                     File "/home/osmc/.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 "/home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/error_handling.py", line 32, in wrapper
                                                       result = func(*args, **kwargs)
                                                     File "/home/osmc/.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 "/home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/routes/play.py", line 117, in route
                                                       videos = api.get_live(name)
                                                     File "/home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/error_handling.py", line 89, in wrapper
                                                       result = func(*args, **kwargs)
                                                     File "/home/osmc/.kodi/addons/plugin.video.twitch/resources/lib/twitch_addon/addon/common/cache.py", line 104, in memoizer
                                                       result = func(*args, **kwargs)
                                                     File "/home/osmc/.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 "/home/osmc/.kodi/addons/script.module.python.twitch/resources/lib/twitch/parser.py", line 52, in m3u8_wrapper
                                                       results = f(*args, **kwargs)
                                                     File "/home/osmc/.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<--

nitramm commented 2 years ago

Issue solved, I'd set the OAuth in the private API section too... I let it blank, now it's working. My bad... Thank you for your work!