Minor variable wording corrections

This commit is contained in:
DevilXD committed 2024-09-14 14:05:58 +02:00
1 parent e9a254ad0a
commit 1684f92afe
1 file changed
+19 -17
+19 -17
View File
@@ -43,9 +43,9 @@ class Stream:
self._stream_url: URLType | None = None self._stream_url: URLType | None = None
@classmethod @classmethod
def from_get_stream(cls, channel: Channel, data: JsonType) -> Stream: def from_get_stream(cls, channel: Channel, channel_data: JsonType) -> Stream:
stream = data["stream"] stream = channel_data["stream"]
settings = data["broadcastSettings"] settings = channel_data["broadcastSettings"]
return cls( return cls(
channel, channel,
id=stream["id"], id=stream["id"],
@@ -56,14 +56,14 @@ class Stream:
@classmethod @classmethod
def from_directory( def from_directory(
cls, channel: Channel, data: JsonType, *, drops_enabled: bool = False cls, channel: Channel, channel_data: JsonType, *, drops_enabled: bool = False
) -> Stream: ) -> Stream:
self = cls( self = cls(
channel, channel,
id=data["id"], id=channel_data["id"],
game=data["game"], # has to be there since we searched with it game=channel_data["game"], # has to be there since we searched with it
viewers=data["viewersCount"], viewers=channel_data["viewersCount"],
title=data["title"], title=channel_data["title"],
) )
self.drops_enabled = drops_enabled self.drops_enabled = drops_enabled
return self return self
@@ -252,26 +252,28 @@ class Channel:
) )
except MinerException as exc: except MinerException as exc:
raise MinerException(f"Channel: {self._login}") from exc raise MinerException(f"Channel: {self._login}") from exc
stream_data: JsonType | None = response["data"]["user"] channel_data: JsonType | None = response["data"]["user"]
if not stream_data: if not channel_data:
return None return None
# fill in channel_id and display name # fill in channel_id and display name
self.id = int(stream_data["id"]) self.id = int(channel_data["id"])
self._display_name = stream_data["displayName"] self._display_name = channel_data["displayName"]
if not stream_data["stream"]: if not channel_data["stream"]:
return None return None
stream = Stream.from_get_stream(self, stream_data) stream = Stream.from_get_stream(self, channel_data)
if not stream.drops_enabled: if not stream.drops_enabled:
try: try:
available_drops: JsonType = await self._twitch.gql_request( available_drops_campaigns: JsonType = await self._twitch.gql_request(
GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(self.id)}) GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(self.id)})
) )
except MinerException: except MinerException:
logger.log(CALL, f"AvailableDrops GQL call failed for channel: {self._login}") logger.log(CALL, f"AvailableDrops GQL call failed for channel: {self._login}")
else: else:
stream.drops_enabled = any( stream.drops_enabled = any(
bool(c["timeBasedDrops"]) bool(campaign["timeBasedDrops"])
for c in (available_drops["data"]["channel"]["viewerDropCampaigns"] or []) for campaign in (
available_drops_campaigns["data"]["channel"]["viewerDropCampaigns"] or []
)
) )
return stream return stream