anxdpanic / plugin.video.twitch

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

Toggle follow doesn't work. #647

Closed deaddrop9 closed 2 years ago

deaddrop9 commented 2 years ago

Attempting to follow a channel using the current version does nothing (no errors, but doesn't follow either)

Please provide any relevant information about your setup

Add-on Version: plugin.video.twitch-2.6.0, script.module.python.twitch-2.0.20
Kodi Version: v19
Kodi GUI Language: English
Operating System: Linux (OSMC)
Operating System Language: English

Expected Behavior

Please describe the behavior you are expecting.

Toggle follow should add or remove a channel from follow list.


Current Behavior

What is the current behavior?

Does nothing


Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Select a channel
  2. Select toggle follow, click yes
  3. Then go to followed channel list, note channel we just followed is not present.
apo86 commented 2 years ago

Still works for me, both follow and unfollow. However it takes a while (maybe 1-2 minutes) specifically for Following Live Channels to update. Changes are immediately visible in Followed Channels though and you can also verify on the Twitch website that the follow/unfollow takes place immediately.

deaddrop9 commented 2 years ago

Further debug and i found this in the logs

DEBUG <general>: script.module.python.twitch: POST QUERY: url: |https://gql.twitch.tv/gql|, params: |{}|, data: |[{'operationName': 'FollowButton_FollowUser', 'variables': {'input': {'disableNotifications': False, 'targetID': '104833324'}}, 'extensions': {'persistedQuery': {'version': 1, 'sha256Hash': '14319edb840c1dfce880dc64fa28a1f4eb69d821901e9e96eb9610d2e52b54f2'}}}]|, headers: |{'Client-ID': 'kimne78kx3ncx6brgo4mv6wki5h1ko', 'Authorization': ''}|, target_func: |_follow_channel|

Looks like the call to gql functions is expecting some sort of authentication token which i appear to be missing.

This is the twitch plugin settings file (oauth keys redacted as XXX)

`

XXX
<setting id="private_oauth_clientid" default="true">kimne78kx3ncx6brgo4mv6wki5h1ko</setting>
<setting id="private_oauth_token" default="true" />
<setting id="menu_browse_live" default="true">true</setting>
<setting id="menu_browse_games" default="true">true</setting>
<setting id="menu_following" default="true">true</setting>
<setting id="menu_search" default="true">true</setting>
<setting id="menu_settings" default="true">true</setting>
<setting id="menu_following_live" default="true">false</setting>
<setting id="menu_following_channels" default="true">false</setting>
<setting id="menu_following_games" default="true">false</setting>
<setting id="menu_search_streams" default="true">false</setting>
<setting id="menu_search_channels" default="true">false</setting>
<setting id="menu_search_games" default="true">false</setting>
<setting id="menu_search_url" default="true">false</setting>
<setting id="video_quality" default="true">0</setting>
<setting id="bandwidth" default="true">2500000</setting>
<setting id="source_frame_rate_limit" default="true">0</setting>
<setting id="video_support_ia_builtin" default="true">false</setting>
<setting id="video_support_ia_addon">true</setting>
<setting id="video_quality_ia">true</setting>
<setting id="title_display" default="true">0</setting>
<setting id="title_truncate" default="true">true</setting>
<setting id="thumbnail_size" default="true">2</setting>
<setting id="refresh_interval" default="true">10</setting>
<setting id="vodcast_highlight" default="true">79</setting>
<setting id="items_per_page" default="true">25</setting>
<setting id="search_history_size" default="true">25</setting>
<setting id="live_reconnect">true</setting>
<setting id="live_notify" default="true">false</setting>
<setting id="live_notify_audible" default="true">false</setting>
<setting id="live_notify_at_start" default="true">true</setting>
<setting id="live_notify_group_start" default="true">false</setting>
<setting id="refresh_cache">true</setting>
<setting id="cache_expire_time" default="true">3</setting>
<setting id="irc_enable" default="true">false</setting>
<setting id="oauth_clientid" default="true" />
<setting id="oauth_redirecturi" default="true" />
<setting id="blacklist_confirm_toggle" default="true">true</setting>
<setting id="menu_browse" default="true">true</setting>
<setting id="menu_browse_clips" default="true">false</setting>
<setting id="menu_browse_ps4" default="true">false</setting>
<setting id="menu_browse_videos" default="true">false</setting>
<setting id="menu_browse_xbox_one" default="true">false</setting>
<setting id="menu_featured" default="true">true</setting>
<setting id="menu_following_clips" default="true">false</setting>
<setting id="oauth_token" default="true">XXX</setting>

`

do i need to set the private_oauth_token and if so how?

apo86 commented 2 years ago

Ah, yes that would be it. You do need the private token as well: https://github.com/anxdpanic/plugin.video.twitch/wiki/Private-API-Credentials---OAuth-Token

deaddrop9 commented 2 years ago

Thanks for the reply, will try that later today.

For others benefit would it be better if the toggle followers button was disabled/hidden or at least checked the private oauth token was set and alerted user to how to enable it rather than the current process where it presents that it succeeded in following but fails in the background?

apo86 commented 2 years ago

Yeah I agree. The GQL API responses look completely different than the regular API responses and there is no custom error handling set up. I played around a bit and it appears that the HTTP response code is always 200 OK, even for errors and the response body looks something like this:

[ { "data": { "unfollowUser": null }, "errors": [ { "message": "unauthenticated", "path": [ "unfollowUser" ] } ], "extensions": { "durationMilliseconds": 3, "operationName": "FollowButton_UnfollowUser", "requestID": "01G0FDP32PGC6S2Z38KJZ9QRQP" } } ]

So it's certainly possible to catch that. The problem is I have no idea if this could have unintended side effects or what other errors might look like, if the GQL error message format is consistent etc.

Here's a scuffed proof of concept: https://github.com/apo86/plugin.video.twitch/commit/9d02ea152099ddf144f9aac1022e6b965c3f0a09

Maybe this is something anxdpanic wants to look at in the future, for now it is what it is.

anxdpanic commented 2 years ago

Submitted a fix to resolve this to the official repository.