text stringlengths 1 93.6k |
|---|
if utils.custom_key_exists("old_export_format", CONFIG_DATA):
|
with open(os.path.join(cwd, export_dir, "results.json"), "x") as fout:
|
json.dump(results, fout)
|
print("Created results.json with recent battles (up to 50 per type).")
|
else:
|
results_dir = os.path.join(export_dir, 'results')
|
if not os.path.exists(results_dir):
|
os.makedirs(results_dir)
|
for result in results:
|
filename = result["data"]["vsHistoryDetail"]["playedTime"].replace("-", "").replace(":", "") + ".json"
|
out_path = os.path.join(results_dir, filename)
|
if not os.path.exists(out_path):
|
with open(out_path, "x") as fout:
|
json.dump(result, fout)
|
print("Updated results directory with recent battles (up to 50 per type).")
|
if coop_results is not None:
|
if utils.custom_key_exists("old_export_format", CONFIG_DATA):
|
with open(os.path.join(cwd, export_dir, "coop_results.json"), "x") as fout:
|
json.dump(coop_results, fout)
|
print("Created coop_results.json with recent Salmon Run jobs (up to 50).")
|
else:
|
coop_results_dir = os.path.join(export_dir, 'coop_results')
|
if not os.path.exists(coop_results_dir):
|
os.makedirs(coop_results_dir)
|
for coop_result in coop_results:
|
filename = coop_result["data"]["coopHistoryDetail"]["playedTime"].replace("-", "").replace(":", "") + ".json"
|
out_path = os.path.join(coop_results_dir, filename)
|
if not os.path.exists(out_path):
|
with open(out_path, "x") as fout:
|
json.dump(coop_result, fout)
|
print("Updated coop_results directory with recent Salmon Run jobs (up to 50).")
|
print("\nHave fun playing Splatoon 3! :) Bye!")
|
sys.exit(0)
|
# manual json upload: -i flag
|
#############################
|
if file_paths: # 2 paths in list
|
if not utils.custom_key_exists("old_export_format", CONFIG_DATA):
|
if os.path.dirname(os.path.join(file_paths[0], ''))[-7:] != "results" \
|
or os.path.basename(file_paths[1])[:8] != "overview":
|
print("Must pass in " + '\033[91m' + "results/" + '\033[0m' + " or " + \
|
'\033[91m' + "coop_results/" + '\033[0m' + " followed by an " +
|
'\033[91m' + "overview.json" + '\033[0m' + ". Exiting.")
|
sys.exit(1)
|
for file_path in file_paths:
|
if not os.path.exists(file_path):
|
path_type = "File" if file_path.endswith(".json") else "Directory"
|
print(f"{path_type} {file_path} does not exist!")
|
sys.exit(1)
|
# argument #1 - results folder or file
|
if not utils.custom_key_exists("old_export_format", CONFIG_DATA):
|
data = []
|
for json_file in os.listdir(file_paths[0]):
|
if json_file.endswith('.json'): # just in case
|
with open(os.path.join(file_paths[0], json_file)) as data_file:
|
contents = json.load(data_file)
|
data.append(contents)
|
else: #old method
|
with open(file_paths[0]) as data_file:
|
try:
|
data = json.load(data_file)
|
except ValueError:
|
print(f"Could not decode JSON object in {os.path.basename(file_paths[0])}.")
|
sys.exit(1)
|
# argument #2 - overview.json
|
with open(file_paths[1]) as data_file:
|
try:
|
overview_file = json.load(data_file)
|
except ValueError:
|
print("Could not decode JSON object in your overview.json.")
|
sys.exit(1)
|
data.reverse()
|
# only upload unuploaded results
|
auth = {'Authorization': f'Bearer {API_KEY}'}
|
resp_b = requests.get("https://stat.ink/api/v3/s3s/uuid-list?lobby=adaptive", headers=auth)
|
resp_j = requests.get("https://stat.ink/api/v3/salmon/uuid-list", headers=auth)
|
try:
|
statink_uploads = json.loads(resp_b.text)
|
statink_uploads.extend(json.loads(resp_j.text))
|
except:
|
print(f"Encountered an error while checking recently-uploaded data. Is stat.ink down?")
|
sys.exit(1)
|
to_upload = []
|
for result in data:
|
try: # ink battle
|
if result["data"]["vsHistoryDetail"] is not None:
|
full_id = utils.b64d(result["data"]["vsHistoryDetail"]["id"])
|
old_uuid = full_id[-36:] # not unique because nintendo hates us
|
new_uuid = str(uuid.uuid5(utils.S3S_NAMESPACE, full_id[-52:]))
|
if new_uuid in statink_uploads:
|
print("Skipping already-uploaded battle.")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.