Log AvailableDrops errors, preventing crashes if possible
This commit is contained in:
1 parent
a536dde677
commit
5dea41a6ab
1 file changed
+13
-8
+13
-8
@@ -9,7 +9,7 @@ from typing import Any, SupportsInt, TYPE_CHECKING
|
|||||||
|
|
||||||
from utils import invalidate_cache, json_minify, Game
|
from utils import invalidate_cache, json_minify, Game
|
||||||
from exceptions import MinerException, RequestException
|
from exceptions import MinerException, RequestException
|
||||||
from constants import GQL_OPERATIONS, ONLINE_DELAY, URLType
|
from constants import CALL, GQL_OPERATIONS, ONLINE_DELAY, URLType
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from twitch import Twitch
|
from twitch import Twitch
|
||||||
@@ -259,13 +259,18 @@ class Channel:
|
|||||||
if not stream_data["stream"]:
|
if not stream_data["stream"]:
|
||||||
return None
|
return None
|
||||||
stream = Stream.from_get_stream(self, stream_data)
|
stream = Stream.from_get_stream(self, stream_data)
|
||||||
available_drops: JsonType = await self._twitch.gql_request(
|
if not stream.drops_enabled:
|
||||||
GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(self.id)})
|
try:
|
||||||
)
|
available_drops: JsonType = await self._twitch.gql_request(
|
||||||
stream.drops_enabled = any(
|
GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(self.id)})
|
||||||
bool(c["timeBasedDrops"])
|
)
|
||||||
for c in (available_drops["data"]["channel"]["viewerDropCampaigns"] or [])
|
except MinerException:
|
||||||
)
|
logger.log(CALL, f"AvailableDrops GQL call failed for channel: {self._login}")
|
||||||
|
else:
|
||||||
|
stream.drops_enabled = any(
|
||||||
|
bool(c["timeBasedDrops"])
|
||||||
|
for c in (available_drops["data"]["channel"]["viewerDropCampaigns"] or [])
|
||||||
|
)
|
||||||
return stream
|
return stream
|
||||||
|
|
||||||
async def update_stream(self, *, trigger_events: bool) -> bool:
|
async def update_stream(self, *, trigger_events: bool) -> bool:
|
||||||
|
|||||||
Reference in new issue
Block a user