Account for game being none
This commit is contained in:
1 parent
97521c11e9
commit
99e1ce0fcc
2 files changed
+13
-5
No files matched your search
+5
-1
@@ -29,7 +29,11 @@ class Stream:
|
|||||||
self.viewer_count = stream["viewersCount"]
|
self.viewer_count = stream["viewersCount"]
|
||||||
self.drops_enabled = any(tag["id"] == DROPS_ENABLED_TAG for tag in stream["tags"])
|
self.drops_enabled = any(tag["id"] == DROPS_ENABLED_TAG for tag in stream["tags"])
|
||||||
settings = data["broadcastSettings"]
|
settings = data["broadcastSettings"]
|
||||||
self.game: Game = Game(settings["game"])
|
self.game: Optional[Game]
|
||||||
|
if settings["game"] is not None:
|
||||||
|
self.game = Game(settings["game"])
|
||||||
|
else:
|
||||||
|
self.game = None
|
||||||
self.title = settings["title"]
|
self.title = settings["title"]
|
||||||
self._timestamp = datetime.now(timezone.utc)
|
self._timestamp = datetime.now(timezone.utc)
|
||||||
|
|
||||||
|
|||||||
@@ -161,8 +161,9 @@ class Twitch:
|
|||||||
for channel in self.channels.values():
|
for channel in self.channels.values():
|
||||||
if (
|
if (
|
||||||
channel.stream is not None # steam online
|
channel.stream is not None # steam online
|
||||||
|
and channel.stream.game is not None # there's game information
|
||||||
and channel.stream.drops_enabled # drops are enabled
|
and channel.stream.drops_enabled # drops are enabled
|
||||||
and channel.stream.game in games # streams a game we can earn drops in
|
and channel.stream.game in games # it's a game we can earn drops in
|
||||||
):
|
):
|
||||||
self.watch(channel)
|
self.watch(channel)
|
||||||
refresh_channels = True
|
refresh_channels = True
|
||||||
@@ -204,10 +205,13 @@ class Twitch:
|
|||||||
await self.claim_points(channel_data["id"], claim_available["id"])
|
await self.claim_points(channel_data["id"], claim_available["id"])
|
||||||
logger.info("Claimed bonus points")
|
logger.info("Claimed bonus points")
|
||||||
i = (i + 1) % 30
|
i = (i + 1) % 30
|
||||||
await asyncio.sleep(59)
|
await asyncio.sleep(58)
|
||||||
|
|
||||||
game = channel.stream.game.name if channel.stream is not None else "<Unknown>"
|
if channel.stream is not None and channel.stream.game is not None:
|
||||||
print(f"Watching: {channel.name}, game: {game}")
|
game_name = channel.stream.game.name
|
||||||
|
else:
|
||||||
|
game_name = "<Unknown>"
|
||||||
|
print(f"Watching: {channel.name}, game: {game_name}")
|
||||||
self._watching_channel = channel
|
self._watching_channel = channel
|
||||||
self._watching_task = asyncio.create_task(watcher(channel))
|
self._watching_task = asyncio.create_task(watcher(channel))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user