Fix None drop context crash
This commit is contained in:
1 parent
1a1117b90c
commit
beca65e271
1 file changed
+12
-11
@@ -371,16 +371,17 @@ class Twitch:
|
|||||||
# we need to use GQL to get the current progress
|
# we need to use GQL to get the current progress
|
||||||
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
|
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
|
||||||
drop_data: JsonType = context["data"]["currentUser"]["dropCurrentSession"]
|
drop_data: JsonType = context["data"]["currentUser"]["dropCurrentSession"]
|
||||||
drop_id = drop_data["dropID"]
|
if drop_data:
|
||||||
drop = self.get_drop(drop_id)
|
drop_id = drop_data["dropID"]
|
||||||
if drop is None:
|
drop = self.get_drop(drop_id)
|
||||||
use_active = True
|
if drop is None:
|
||||||
logger.error(f"Missing drop: {drop_id}")
|
use_active = True
|
||||||
elif not drop.can_earn(channel):
|
logger.error(f"Missing drop: {drop_id}")
|
||||||
use_active = True
|
elif not drop.can_earn(channel):
|
||||||
else:
|
use_active = True
|
||||||
drop.update_minutes(drop_data["currentMinutesWatched"])
|
else:
|
||||||
drop.display()
|
drop.update_minutes(drop_data["currentMinutesWatched"])
|
||||||
|
drop.display()
|
||||||
if use_active:
|
if use_active:
|
||||||
# Sometimes, even GQL fails to give us the correct drop.
|
# Sometimes, even GQL fails to give us the correct drop.
|
||||||
# In that case, we can use the locally cached inventory to try
|
# In that case, we can use the locally cached inventory to try
|
||||||
@@ -515,7 +516,7 @@ class Twitch:
|
|||||||
for attempt in range(8):
|
for attempt in range(8):
|
||||||
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
|
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
|
||||||
drop_data: JsonType = context["data"]["currentUser"]["dropCurrentSession"]
|
drop_data: JsonType = context["data"]["currentUser"]["dropCurrentSession"]
|
||||||
if drop_data["dropID"] != drop.id:
|
if not drop_data or drop_data["dropID"] != drop.id:
|
||||||
break
|
break
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
self.restart_watching()
|
self.restart_watching()
|
||||||
|
|||||||
Reference in new issue
Block a user