fetch previous salmon run shifts (fix #4)

This commit is contained in:
eli fessler
2022-09-10 05:26:17 -10:00
parent 02c6af096b
commit 357cbea4ac

19
s3s.py
View File

@@ -245,14 +245,16 @@ def fetch_json(which, separate=False, exportall=False):
query1 = requests.post(GRAPHQL_URL, data=gen_graphql_body(sha), headers=headbutt(), cookies=dict(_gtoken=GTOKEN))
query1_resp = json.loads(query1.text)
# prefetch_checks() ensures this exists
try: # ink battle
for b in query1_resp["data"]["latestBattleHistories"]["historyGroups"]["nodes"][0]["historyDetails"]["nodes"]:
battle_ids.append(b["id"])
except: # salmon run job
# prefetch_checks() ensures these paths exist
try: # ink battles
for battle_group in query1_resp["data"]["latestBattleHistories"]["historyGroups"]["nodes"]:
for battle in battle_group["historyDetails"]["nodes"]:
battle_ids.append(battle["id"])
except: # salmon run jobs
try:
for j in query1_resp["data"]["coopResult"]["historyGroups"]["nodes"][0]["historyDetails"]["nodes"]:
job_ids.append(j["id"])
for shift in query1_resp["data"]["coopResult"]["historyGroups"]["nodes"]:
for job in shift["historyDetails"]["nodes"]:
job_ids.append(job["id"])
except:
pass
@@ -784,7 +786,8 @@ def main():
# exporting results to file
###########################
if outfile:
print("\nFetching your JSON files to export locally...")
prefetch_checks()
print("\nFetching your JSON files to export locally... this might take a while.")
try:
parents, results, coop_results = fetch_json("both", True, True) # calls prefetch_checks() to gen or check tokens
except: