Skip to content

Commit

Permalink
fix Error: KeyError: 'data' #593
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavydov committed Oct 6, 2024
1 parent 78ce7b7 commit a09e0cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions TwitchChannelPointsMiner/classes/Twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# from urllib.parse import quote
# from base64 import urlsafe_b64decode
# from datetime import datetime
from typing import Dict, Any

from TwitchChannelPointsMiner.classes.entities.Campaign import Campaign
from TwitchChannelPointsMiner.classes.entities.Drop import Drop
Expand Down Expand Up @@ -46,6 +47,7 @@
)

logger = logging.getLogger(__name__)
JsonType = Dict[str, Any]


class Twitch(object):
Expand Down Expand Up @@ -492,9 +494,14 @@ def send_minute_watched_events(self, streamers, priority, chunk_size=3):
logger.debug(
f"Sent PlaybackAccessToken request for {streamers[index]}"
)
signature = responsePlaybackAccessToken["data"]['streamPlaybackAccessToken']["signature"]
value = responsePlaybackAccessToken["data"]['streamPlaybackAccessToken']["value"]
signature: JsonType | None = responsePlaybackAccessToken["data"].get(
'streamPlaybackAccessToken', {}).get("signature")
value: JsonType | None = responsePlaybackAccessToken["data"].get(
'streamPlaybackAccessToken', {}).get("value")

if not signature or not value:
logger.error(
f"Invalid response from Twitch: {responsePlaybackAccessToken}")
continue

# encoded_value = quote(json.dumps(value))
Expand Down

0 comments on commit a09e0cb

Please sign in to comment.