diff --git a/channel.py b/channel.py index a026849..9cc882b 100644 --- a/channel.py +++ b/channel.py @@ -29,7 +29,11 @@ class Stream: self.viewer_count = stream["viewersCount"] self.drops_enabled = any(tag["id"] == DROPS_ENABLED_TAG for tag in stream["tags"]) 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._timestamp = datetime.now(timezone.utc) diff --git a/twitch.py b/twitch.py index 69bbff1..4a56371 100644 --- a/twitch.py +++ b/twitch.py @@ -161,8 +161,9 @@ class Twitch: for channel in self.channels.values(): if ( 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.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) refresh_channels = True @@ -204,10 +205,13 @@ class Twitch: await self.claim_points(channel_data["id"], claim_available["id"]) logger.info("Claimed bonus points") i = (i + 1) % 30 - await asyncio.sleep(59) + await asyncio.sleep(58) - game = channel.stream.game.name if channel.stream is not None else "" - print(f"Watching: {channel.name}, game: {game}") + if channel.stream is not None and channel.stream.game is not None: + game_name = channel.stream.game.name + else: + game_name = "" + print(f"Watching: {channel.name}, game: {game_name}") self._watching_channel = channel self._watching_task = asyncio.create_task(watcher(channel))