Skip to content

Commit 3e17c80

Browse files
committed
Black Fixes
1 parent 254d383 commit 3e17c80

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

experiment.py

+8-26
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,28 @@
1717
}
1818

1919

20-
async def claim_offer(
21-
offer_id: str, item: dict, client: httpx.AsyncClient, headers: dict
22-
) -> True:
20+
async def claim_offer(offer_id: str, item: dict, client: httpx.AsyncClient, headers: dict) -> True:
2321
if not item["offers"][0]["offerSelfConnection"]["eligibility"]["isClaimed"]:
2422
if (
2523
item["offers"][0]["offerSelfConnection"]["eligibility"]["canClaim"] is False
26-
and item["offers"][0]["offerSelfConnection"]["eligibility"][
27-
"missingRequiredAccountLink"
28-
]
29-
is True
24+
and item["offers"][0]["offerSelfConnection"]["eligibility"]["missingRequiredAccountLink"] is True
3025
):
31-
log.error(
32-
f"Cannot collect game `{item['game']['assets']['title']}`, account link required."
33-
)
26+
log.error(f"Cannot collect game `{item['game']['assets']['title']}`, account link required.")
3427
return
3528
log.info(f"Collecting offer for {item['game']['assets']['title']}")
3629
claim_payload = {
3730
"operationName": "placeOrdersDetailPage",
3831
"variables": {
3932
"input": {
4033
"offerIds": [offer_id],
41-
"attributionChannel": '{"eventId":"ItemDetailRootPage:'
42-
+ offer_id
43-
+ '","page":"ItemDetailPage"}',
34+
"attributionChannel": '{"eventId":"ItemDetailRootPage:' + offer_id + '","page":"ItemDetailPage"}',
4435
}
4536
},
4637
"extensions": {},
4738
"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\nmutation 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
4839
}
4940

50-
response = await client.post(
51-
gql_url, headers=headers, data=json.dumps(claim_payload)
52-
)
41+
response = await client.post(gql_url, headers=headers, data=json.dumps(claim_payload))
5342
if response.json()["data"]["placeOrders"]["error"] is not None:
5443
log.error(f"Error: {response.json()['data']['placeOrders']['error']}")
5544

@@ -68,22 +57,15 @@ async def primelooter(cookie_file):
6857
for _c in jar:
6958
client.cookies.jar.set_cookie(_c)
7059

71-
html_body = (
72-
await client.get("https://gaming.amazon.com/home", headers=base_headers)
73-
).text
60+
html_body = (await client.get("https://gaming.amazon.com/home", headers=base_headers)).text
7461
matches = re.findall(r"name='csrf-key' value='(.*)'", html_body)
7562
json_headers["csrf-token"] = matches[0]
7663

77-
response = await client.post(
78-
gql_url, headers=json_headers, data=json.dumps(offers_payload)
79-
)
64+
response = await client.post(gql_url, headers=json_headers, data=json.dumps(offers_payload))
8065
data = response.json()["data"]["inGameLoot"]["items"]
8166

8267
# although insanely low, python WILL garbage collect running coroutines if their references
8368
# aren't stored somewhere, therefore we noqa the Flake8 issue yelling at us about it.
8469
coros = await asyncio.gather( # noqa: F841
85-
*[
86-
claim_offer(item["offers"][0]["id"], item, client, json_headers)
87-
for item in data
88-
]
70+
*[claim_offer(item["offers"][0]["id"], item, client, json_headers) for item in data]
8971
)

0 commit comments

Comments
 (0)