From 75179dc69f76b2fbcccedfdf916c211efc3adaac Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sat, 22 Jan 2022 19:32:13 +0100 Subject: [PATCH] Fix isEnabled KeyError --- channel.py | 4 +++- constants.py | 2 +- inventory.py | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/channel.py b/channel.py index 0985de1..dadb0bc 100644 --- a/channel.py +++ b/channel.py @@ -200,7 +200,9 @@ class Channel: ) if response: stream_data = response["data"]["user"] - self.id = int(stream_data["id"]) # fill channel_id + # fill channel_id and name + self.id = int(stream_data["id"]) + self.name = stream_data["displayName"] if stream_data["stream"]: self._stream = Stream(self, stream_data) else: diff --git a/constants.py b/constants.py index 61a8831..0556a56 100644 --- a/constants.py +++ b/constants.py @@ -109,7 +109,7 @@ GQL_OPERATIONS: Dict[str, GQLOperation] = { # returns all in-progress campaigns "Inventory": GQLOperation( "Inventory", - "e0765ebaa8e8eeb4043cc6dfeab3eac7f682ef5f724b81367e6e55c7aef2be4c", + "27f074f54ff74e0b05c8244ef2667180c2f911255e589ccd693a1a52ccca7367", ), # returns current state of drops (current drop progress) "CurrentDrop": GQLOperation( diff --git a/inventory.py b/inventory.py index c450a45..c355b9c 100644 --- a/inventory.py +++ b/inventory.py @@ -12,6 +12,11 @@ if TYPE_CHECKING: from twitch import Twitch +class Benefit: + def __init__(self) -> None: + pass + + class BaseDrop: def __init__(self, campaign: DropsCampaign, data: JsonType, claimed_benefits: Set[str]): self._twitch: Twitch = campaign._twitch @@ -172,10 +177,10 @@ class DropsCampaign: allowed = data["allow"] self.allowed_channels: List[Channel] = ( [ - Channel(twitch, ch["id"], ch["displayName"], priority=True) + Channel(twitch, ch["id"], ch.get("displayName", ch["name"]), priority=True) for ch in allowed["channels"] ] - if allowed["channels"] and allowed["isEnabled"] else [] + if allowed["channels"] and allowed.get("isEnabled", True) else [] ) self.timed_drops: Dict[str, TimedDrop] = { drop_data["id"]: TimedDrop(self, drop_data, claimed_benefits)