streamlink / streamlink-twitch-gui

A multi platform Twitch.tv browser for Streamlink
https://streamlink.github.io/streamlink-twitch-gui/
MIT License
2.66k stars 201 forks source link

Follow game button not working #549

Closed JonGuithub closed 6 years ago

JonGuithub commented 6 years ago

Checklist

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 commented 6 years ago

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:

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 :relieved:

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.