Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow game button not working #549

Closed
1 of 5 tasks
JonGuithub opened this issue Mar 25, 2018 · 4 comments
Closed
1 of 5 tasks

Follow game button not working #549

JonGuithub opened this issue Mar 25, 2018 · 4 comments

Comments

@JonGuithub
Copy link

JonGuithub commented Mar 25, 2018

Checklist

  • This is a bug report.
  • This is a feature request.
  • I understand the difference between Streamlink and Streamlink Twitch GUI.
  • I tried solving my issue by reading the project's wiki first.
  • I have read the contribution guidelines und used the search function to find already existing threads.

Description

I can't follow or unfollow games. When I click the heart icon on any game page it just shakes for a couple of seconds but does not actually follow the game. The icon remains red.
If I go to my game list and try to unfollow a game the same thing happens. I click the now green heart icon but it does not unfollow the game

Expected / Actual behavior

When the follow button is clicked, the color should change to green and the game should appear on your list of followed games

Reproduction steps

  1. Open streamlink twitch gui and go to any game page.
  2. Click the heart (or F key) to follow said game

Environment details

Operating system and version: Windows 7
Streamlink Twitch GUI version: 1.4.1
Streamlink version: 0.8.1
Configuration details: ...

...

Comments, logs, screenshots, etc.

Not sure where to get the logs.

Update: I tried deleting the whole user data folder (I have a copy of the older one just in case) from appdata and start from scratch but I get the same issue with default settings

@bastimeyer
Copy link
Member

The code responsible for (un)following games hasn't been changed in over a year. It looks like Twitch has removed the endpoints from their private API. As you can see, the test fixtures of the respective API calls haven't been changed and the buttons are still doing their job correctly:
https://github.com/streamlink/streamlink-twitch-gui/blame/99a9d52b8d71cf2245971fb5502ae846ce76276b/src/test/fixtures/models/twitch/GameFollowed.json#L41-L65

Since you might wonder why they would remove API endpoints, let me explain the current situation real quick without trying to write a wall of text. There are a couple of different Twitch APIs:

  • api.twitch.tv/kraken (v3)
    Old main public API with many inconsistencies. Officially deprecated, will be shut down on 2018-12-31. Not being used here anymore since almost two years.
  • api.twitch.tv/kraken (v5)
    Main public API with less inconsistencies than v3 and a few more features like communities, but doesn't support everything, like (un)following games. Officially deprecated, will be shut down on 2018-12-31. Currently being used by almost every data model here.
  • api.twitch.tv/api (undocumented, private)
    Was being used by the Twitch website for many years for experimental stuff. Super inconsistent. Being used here for (un)following games, requesting the list of hosted streams and followed live games and also for requesting the channel descriptions, since the other APIs don't support any of this.
  • api.twitch.tv/helix (new Twitch API)
    New API namespace which has been introduced at the end of last year. Replaces both kraken APIs and is more consistent, but is still missing many features. A terrible decision of them deprecating and removing the kraken API while not having implemented all features in their new API yet. Also introduces rate limiting, which might kill this app, time will tell. It's a total shit show. Super disappointing...
  • GraphQL based API
    Being used by the new Twitch website. Incompatible with the other APIs, which are REST based instead. The (un)follow games buttons on the new Twitch website use this API, among everything else. Can't be implemented here now and I'm not sure if it ever will be. Needs further research.

So what can I do now? I'm not sure whether they've just changed the API endpoints, because they were terribly inconsistent, or if they really have removed them. Since it's not documented and not being used anymore on their website, it's kinda difficult to figure this out. If they have been removed, this means that the buttons have to be removed here for now.

I'll try to figure this out over the next few days. I was about to release v1.5.0 and now this... So typical...

@JonGuithub
Copy link
Author

Thanks for the detailed response. I'ts a bummer twitch apis are so badly documented, I'm taking a peak at the new api documents and it says 30 queries per minute without a token or 120 with one. I guess that's too few, I don't know how requests are made but I suppose each image for a game is one. If it's like that then simply scrolling down the list of games will reach that limit really easy. Anyway take your time and thanks for your work. I hope you can continue developing streamlink twitch gui, It is the best twitch app by far

@bastimeyer
Copy link
Member

I suppose each image for a game is one

CDN requests are not API calls. But the maximum number of API calls per minute is still too low for this app, since every user who is logged in and has enabled desktop notifications makes at least one query per minute. Additionally, while viewing streams, every user also makes one request per minute for each stream being watched in order to update the stream title and viewer counts. The webhooks of the new API (websocket connections) try to solve this stupid polling mechanic, but Twitch currently doesn't provide access to the data which is required here and I don't know if this will be added in the future. I'm not sure how many users Streamlink Twitch GUI has and how high the concurrent users peak is or can be at certain times, but the latest version has been downloaded ~76k times from the Github releases page alone, repo clones and external downloads excluded, so I can safely say that it won't suffice. Special Twitch app creators can ask for an increase of the API request limit, but I'm not really sure whether Twitch will do this for both Streamlink and Streamlink Twitch GUI, as these two programs basically mean a loss of profit in terms of ads for them and me asking from my position would look kinda bold/impudent, if you know what I mean... To my defense, the old Twitch website was WAY worse and was polling the APIs like crazy. I've always tried to keep the amount of queries as low as possible while not trying to sacrifice the user experience too much.

@bastimeyer
Copy link
Member

bastimeyer commented Mar 29, 2018

Okay, found the time to investigate it and also found a solution, which means that the follow games buttons don't have to be removed 😌

It looks like they've fixed some of the inconsistencies I've mentioned earlier and changed the URL pattern from

GET https://api.twitch.tv/api/users/:username/follows/games/isFollowing
PUT https://api.twitch.tv/api/users/:username/follows/games/follow
{"name":":gamename"}
DELETE https://api.twitch.tv/api/users/:username/follows/games/unfollow
{"name":":gamename"}

to

GET https://api.twitch.tv/api/users/:username/follows/games/:gamename
PUT https://api.twitch.tv/api/users/:username/follows/games/:gamename
DELETE https://api.twitch.tv/api/users/:username/follows/games/:gamename

This is still inconsistent with the requests for (un)following channels, because those are using IDs instead of names, which is much more sane. Don't ask me, why they've changed it now, especially since they are not using this API anymore on their website, but it works, at least for now.

I'll push a fix later this day or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants