From 163a056b338665c64669270fb87b65a8c473db7e Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sun, 15 Oct 2023 22:37:48 +0200 Subject: [PATCH] Experimental drops_enabled via AvailableDrops --- channel.py | 10 +++++++++- constants.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/channel.py b/channel.py index 14ff010d..6b30c3a8 100644 --- a/channel.py +++ b/channel.py @@ -255,7 +255,15 @@ async def get_stream(self) -> Stream | None: self._display_name = stream_data["displayName"] if not stream_data["stream"]: return None - return Stream.from_get_stream(self, stream_data) + stream = Stream.from_get_stream(self, stream_data) + available_drops: JsonType = await self._twitch.gql_request( + GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(self.id)}) + ) + stream.drops_enabled = any( + bool(c["timeBasedDrops"]) + for c in available_drops["data"]["channel"]["viewerDropCampaigns"] + ) + return stream async def update_stream(self, *, trigger_events: bool) -> bool: """ diff --git a/constants.py b/constants.py index 0c94030a..bf4da827 100644 --- a/constants.py +++ b/constants.py @@ -297,7 +297,7 @@ def with_variables(self, variables: JsonType) -> GQLOperation: }, ), # returns drops available for a particular channel (unused) - "ChannelDrops": GQLOperation( + "AvailableDrops": GQLOperation( "DropsHighlightService_AvailableDrops", "9a62a09bce5b53e26e64a671e530bc599cb6aab1e5ba3cbd5d85966d3940716f", variables={