13
13
"operationName" : "OffersContext_Offers_And_Items" ,
14
14
"variables" : {"pageSize" : 999 },
15
15
"extensions" : {},
16
- "query" : "query OffersContext_Offers_And_Items($dateOverride: Time, $pageSize: Int) {\n inGameLoot: items(\n collectionType: LOOT\n dateOverride: $dateOverride\n pageSize: $pageSize\n ) {\n items {\n ...Item\n __typename\n }\n __typename\n }\n }\n \n fragment Item on Item {\n id\n isDirectEntitlement\n requiresLinkBeforeClaim\n grantsCode\n isDeepLink\n isFGWP\n offers {\n ...Item_Offer\n __typename\n }\n game {\n ...Game\n __typename\n }\n __typename\n }\n \n \n fragment Item_Offer on Offer {\n id\n offerSelfConnection {\n eligibility {\n ...Item_Offer_Eligibility\n __typename\n }\n __typename\n }\n __typename\n }\n \n fragment Item_Offer_Eligibility on OfferEligibility {\n isClaimed\n canClaim\n missingRequiredAccountLink\n }\n \n fragment Game on GameV2 {\n id\n assets {\n title\n publisher\n }\n }\n " ,
16
+ "query" : "query OffersContext_Offers_And_Items($dateOverride: Time, $pageSize: Int) {\n inGameLoot: items(\n collectionType: LOOT\n dateOverride: $dateOverride\n pageSize: $pageSize\n ) {\n items {\n ...Item\n __typename\n }\n __typename\n }\n }\n \n fragment Item on Item {\n id\n isDirectEntitlement\n requiresLinkBeforeClaim\n grantsCode\n isDeepLink\n isFGWP\n offers {\n ...Item_Offer\n __typename\n }\n game {\n ...Game\n __typename\n }\n __typename\n }\n \n \n fragment Item_Offer on Offer {\n id\n offerSelfConnection {\n eligibility {\n ...Item_Offer_Eligibility\n __typename\n }\n __typename\n }\n __typename\n }\n \n fragment Item_Offer_Eligibility on OfferEligibility {\n isClaimed\n canClaim\n missingRequiredAccountLink\n }\n \n fragment Game on GameV2 {\n id\n assets {\n title\n publisher\n }\n }\n " , # noqa: E501 TODO: This needs to become a non \n formatted string somewhere, just not doing it now
17
17
}
18
18
19
19
20
20
async def claim_offer (offer_id : str , item : dict , client : httpx .AsyncClient , headers : dict ) -> True :
21
- if item ["offers" ][0 ]["offerSelfConnection" ]["eligibility" ]["isClaimed" ] != True :
21
+ if not item ["offers" ][0 ]["offerSelfConnection" ]["eligibility" ]["isClaimed" ]:
22
22
if (
23
- item ["offers" ][0 ]["offerSelfConnection" ]["eligibility" ]["canClaim" ] == False
24
- and item ["offers" ][0 ]["offerSelfConnection" ]["eligibility" ]["missingRequiredAccountLink" ] == True
23
+ item ["offers" ][0 ]["offerSelfConnection" ]["eligibility" ]["canClaim" ] is False
24
+ and item ["offers" ][0 ]["offerSelfConnection" ]["eligibility" ]["missingRequiredAccountLink" ] is True
25
25
):
26
26
log .error (f"Cannot collect game `{ item ['game' ]['assets' ]['title' ]} `, account link required." )
27
27
return
@@ -35,11 +35,11 @@ async def claim_offer(offer_id: str, item: dict, client: httpx.AsyncClient, head
35
35
}
36
36
},
37
37
"extensions" : {},
38
- "query" : "fragment Place_Orders_Payload_Order_Information on OfferOrderInformation {\n catalogOfferId\n claimCode\n entitledAccountId\n entitledAccountName\n id\n orderDate\n orderState\n __typename\n }\n \n mutation placeOrdersDetailPage($input: PlaceOrdersInput!) {\n placeOrders(input: $input) {\n error {\n code\n __typename\n }\n orderInformation {\n ...Place_Orders_Payload_Order_Information\n __typename\n }\n __typename\n }\n }\n " ,
38
+ "query" : "fragment Place_Orders_Payload_Order_Information on OfferOrderInformation {\n catalogOfferId\n claimCode\n entitledAccountId\n entitledAccountName\n id\n orderDate\n orderState\n __typename\n }\n \n mutation placeOrdersDetailPage($input: PlaceOrdersInput!) {\n placeOrders(input: $input) {\n error {\n code\n __typename\n }\n orderInformation {\n ...Place_Orders_Payload_Order_Information\n __typename\n }\n __typename\n }\n }\n " , # noqa: E501 TODO: This needs to become a non \n formatted string somewhere, just not doing it now
39
39
}
40
40
41
41
response = await client .post (gql_url , headers = headers , data = json .dumps (claim_payload ))
42
- if response .json ()["data" ]["placeOrders" ]["error" ] != None :
42
+ if response .json ()["data" ]["placeOrders" ]["error" ] is not None :
43
43
log .error (f"Error: { response .json ()['data' ]['placeOrders' ]['error' ]} " )
44
44
45
45
@@ -64,6 +64,8 @@ async def primelooter(cookie_file):
64
64
response = await client .post (gql_url , headers = json_headers , data = json .dumps (offers_payload ))
65
65
data = response .json ()["data" ]["inGameLoot" ]["items" ]
66
66
67
- coros = await asyncio .gather (
67
+ # although insanely low, python WILL garbage collect running coroutines if their references
68
+ # aren't stored somewhere, therefore we noqa the Flake8 issue yelling at us about it.
69
+ coros = await asyncio .gather ( # noqa: F841
68
70
* [claim_offer (item ["offers" ][0 ]["id" ], item , client , json_headers ) for item in data ]
69
71
)
0 commit comments