From 2a1fc1243c9bc5a8496efdf0812e033b02cfe9f1 Mon Sep 17 00:00:00 2001 From: apo86 <57818762+apo86@users.noreply.github.com> Date: Tue, 22 Jun 2021 12:20:07 +0200 Subject: [PATCH 1/3] Update streams.py Update to get reruns to work --- resources/lib/twitch/api/v5/streams.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lib/twitch/api/v5/streams.py b/resources/lib/twitch/api/v5/streams.py index 48d990c..62a0266 100644 --- a/resources/lib/twitch/api/v5/streams.py +++ b/resources/lib/twitch/api/v5/streams.py @@ -19,8 +19,8 @@ # required scope: none @query def by_id(channel_id, stream_type=StreamType.LIVE): - q = Qry('streams/{channel_id}', use_token=False) - q.add_urlkw(keys.CHANNEL_ID, channel_id) + q = Qry('streams', use_token=False) + q.add_param(keys.CHANNEL, channel_id) q.add_param(keys.STREAM_TYPE, StreamType.validate(stream_type), StreamType.LIVE) return q From 27b6e714b99d8e4b2174b1d60d0d8a41481f5ec6 Mon Sep 17 00:00:00 2001 From: apo86 <57818762+apo86@users.noreply.github.com> Date: Fri, 13 Aug 2021 20:30:43 +0200 Subject: [PATCH 2/3] Update users.py Change follow/unfollow to GQL queries, due to discontinued official API endpoints (https://discuss.dev.twitch.tv/t/deprecation-of-create-and-delete-follows-api-endpoints) --- resources/lib/twitch/api/v5/users.py | 42 ++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/resources/lib/twitch/api/v5/users.py b/resources/lib/twitch/api/v5/users.py index 358a5a4..273a7f4 100644 --- a/resources/lib/twitch/api/v5/users.py +++ b/resources/lib/twitch/api/v5/users.py @@ -80,20 +80,44 @@ def check_follows(user_id, channel_id): # required scope: user_follows_edit @query -def follow_channel(user_id, channel_id, notifications=Boolean.FALSE): - q = Qry('users/{user_id}/follows/channels/{channel_id}', method=methods.PUT) - q.add_urlkw(keys.USER_ID, user_id) - q.add_urlkw(keys.CHANNEL_ID, channel_id) - q.add_data(keys.NOTIFICATIONS, Boolean.validate(notifications), Boolean.FALSE) +def follow_channel(channel_id, headers={}, notifications=False): + data = [{ + "operationName": "FollowButton_FollowUser", + "variables": { + "input": { + "disableNotifications": notifications, + "targetID": str(channel_id) + } + }, + "extensions": { + "persistedQuery": { + "version": 1, + "sha256Hash": "14319edb840c1dfce880dc64fa28a1f4eb69d821901e9e96eb9610d2e52b54f2" + } + } + }] + q = GQLQry('', headers=headers, data=data, use_token=False) return q # required scope: user_follows_edit @query -def unfollow_channel(user_id, channel_id): - q = Qry('users/{user_id}/follows/channels/{channel_id}', method=methods.DELETE) - q.add_urlkw(keys.USER_ID, user_id) - q.add_urlkw(keys.CHANNEL_ID, channel_id) +def unfollow_channel(channel_id, headers={}): + data = [{ + "operationName": "FollowButton_UnfollowUser", + "variables": { + "input": { + "targetID": str(channel_id) + } + }, + "extensions": { + "persistedQuery": { + "version": 1, + "sha256Hash": "29783a1dac24124e02f7295526241a9f1476cd2f5ce1e394f93ea50c253d8628" + } + } + }] + q = GQLQry('', headers=headers, data=data, use_token=False) return q From 87c8a7d616f7dc86cabf432cad2978e4daebda8d Mon Sep 17 00:00:00 2001 From: apo86 <57818762+apo86@users.noreply.github.com> Date: Fri, 13 Aug 2021 20:38:10 +0200 Subject: [PATCH 3/3] Update users.py --- resources/lib/twitch/api/v5/users.py | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/lib/twitch/api/v5/users.py b/resources/lib/twitch/api/v5/users.py index 273a7f4..044bbd4 100644 --- a/resources/lib/twitch/api/v5/users.py +++ b/resources/lib/twitch/api/v5/users.py @@ -13,6 +13,7 @@ from ... import keys, methods from ...api.parameters import Boolean, Direction, SortBy from ...queries import V5Query as Qry +from ...queries import GQLQuery as GQLQry from ...queries import query