Fix isEnabled KeyError

This commit is contained in:
DevilXD
2022-01-22 19:32:13 +01:00
parent 7e5f34748b
commit 75179dc69f
3 changed files with 11 additions and 4 deletions

View File

@@ -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:

View File

@@ -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(

View File

@@ -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)