Skip to content

Commit 020a442

Browse files
committed
Replace deprecated users/follows API endpoint with channels/followed
1 parent 6d08ac0 commit 020a442

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

twitch_indicator/auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def acquire_token(self):
5151
"client_id": TWITCH_CLIENT_ID,
5252
"state": state,
5353
"redirect_uri": TWITCH_AUTH_REDIRECT_URI,
54-
"scope": TWITCH_AUTH_SCOPES,
54+
"scope": " ".join(TWITCH_AUTH_SCOPES),
5555
}
5656
url_parts[4] = urlencode(query)
5757
url = urlunparse(url_parts)

twitch_indicator/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
TWITCH_API_URL = "https://api.twitch.tv/helix/"
88
TWITCH_AUTH_URL = "https://id.twitch.tv/oauth2/authorize"
99
TWITCH_AUTH_REDIRECT_URI = "twitch-indicator-auth://authorize"
10-
TWITCH_AUTH_SCOPES = "user:read:email"
10+
TWITCH_AUTH_SCOPES = ["user:read:follows"]
1111
TWITCH_CLIENT_ID = "lp42a3ot0vosrva84upd4up077f6vd"
1212
TWITCH_API_LIMIT = 100
1313
DEFAULT_AVATAR = (

twitch_indicator/twitch.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def clear_cache(self):
2828

2929
def fetch_followed_channels(self, user_id):
3030
"""Fetch user followed channels and return a list with channel ids."""
31-
url = self.build_url("users/follows", {"from_id": user_id})
31+
loc = "channels/followed"
32+
url = self.build_url(loc, {"user_id": user_id})
3233
resp = self.get_api_response(url)
3334

3435
total = int(resp["total"])
@@ -42,16 +43,16 @@ def fetch_followed_channels(self, user_id):
4243
last = resp
4344
while fetched < total:
4445
url = self.build_url(
45-
"users/follows",
46-
{"after": last["pagination"]["cursor"], "from_id": user_id},
46+
loc,
47+
{"after": last["pagination"]["cursor"], "user_id": user_id},
4748
)
4849
nxt = self.get_api_response(url)
4950

5051
fetched += len(nxt["data"])
5152
data += nxt["data"]
5253
last = nxt
5354

54-
return [{"id": int(data["to_id"]), "name": data["to_name"]} for data in data]
55+
return [{"id": int(data["broadcaster_id"]), "name": data["broadcaster_name"]} for data in data]
5556

5657
def fetch_live_streams(self, channel_ids):
5758
"""Fetches live streams data from Twitch, and returns as list of

0 commit comments

Comments
 (0)