Skip to content

Commit

Permalink
Check for 'error' in request_subscription responses
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Dec 29, 2024
1 parent 8b8386f commit 7a5e261
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions server/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,17 @@ async def request_subscription(self, name, broadcaster_user_id, subscription_typ
TWITCH_EVENTSUB_API_URL, headers=self.headers, json=data
) as resp:
response_data = await resp.json()
try:
subs = response_data["data"][0]
self.subscriptions[subs["id"]] = subs
except KeyError:
log.error(
"No 'data' in twitch request_subscription() json response: %s",
response_data,
)
if "error" in response_data:
log.debug("request_subscription response: %s", response_data)
else:
try:
subs = response_data["data"][0]
self.subscriptions[subs["id"]] = subs
except KeyError:
log.error(
"No 'data' in twitch request_subscription() json response: %s",
response_data,
)

async def get_subscriptions(self):
log.debug("--- get_subscriptions from twitch ---")
Expand Down

0 comments on commit 7a5e261

Please sign in to comment.