mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-05-31 09:29:37 +00:00
Account for game being none
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
12
twitch.py
12
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 "<Unknown>"
|
||||
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 = "<Unknown>"
|
||||
print(f"Watching: {channel.name}, game: {game_name}")
|
||||
self._watching_channel = channel
|
||||
self._watching_task = asyncio.create_task(watcher(channel))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user