mirror of
https://github.com/frozenpandaman/s3s.git
synced 2026-09-29 12:46:55 -05:00
send uuid v5s instead of (non-unique!) splatnet battle uuids (#29)
This commit is contained in:
27
s3s.py
27
s3s.py
@@ -4,14 +4,14 @@
|
||||
# https://github.com/frozenpandaman/s3s
|
||||
# License: GPLv3
|
||||
|
||||
import argparse, datetime, json, os, re, requests, sys, time
|
||||
import argparse, datetime, json, os, re, requests, sys, time, uuid
|
||||
import msgpack
|
||||
from packaging import version
|
||||
from PIL import Image
|
||||
from io import BytesIO
|
||||
import iksm, utils#, utils_ss
|
||||
|
||||
A_VERSION = "0.1.3"
|
||||
A_VERSION = "0.1.4"
|
||||
|
||||
DEBUG = False
|
||||
|
||||
@@ -390,7 +390,9 @@ def prepare_battle_result(battle, ismonitoring, overview_data=None):
|
||||
|
||||
## UUID ##
|
||||
##########
|
||||
payload["uuid"] = utils.b64d(battle["id"])
|
||||
full_id = utils.b64d(battle["id"])
|
||||
s3s_namespace = uuid.UUID('b3a2dbf5-2c09-4792-b78c-00b548b70aeb')
|
||||
payload["uuid"] = str(uuid.uuid5(s3s_namespace, full_id[-52:])) # input format: <YYYYMMDD>T<HHMMSS>_<uuid>
|
||||
|
||||
## MODE ##
|
||||
##########
|
||||
@@ -1119,15 +1121,24 @@ def main():
|
||||
print(f"Encountered an error while checking recently-uploaded {noun}. Is stat.ink down?")
|
||||
sys.exit(1)
|
||||
|
||||
data_new = []
|
||||
to_upload = []
|
||||
for battle in data:
|
||||
if battle["data"]["vsHistoryDetail"] != None:
|
||||
battle_uuid = utils.b64d(battle["data"]["vsHistoryDetail"]["id"])
|
||||
full_id = utils.b64d(battle["data"]["vsHistoryDetail"]["id"])
|
||||
old_uuid = full_id[-36:] # not unique because nintendo hates us
|
||||
s3s_namespace = uuid.UUID('b3a2dbf5-2c09-4792-b78c-00b548b70aeb')
|
||||
new_uuid = str(uuid.uuid5(s3s_namespace, full_id[-52:]))
|
||||
|
||||
if battle_uuid not in statink_uploads:
|
||||
data_new.append(battle)
|
||||
if new_uuid in statink_uploads:
|
||||
print("Skipping already-uploaded battle.")
|
||||
continue
|
||||
if old_uuid in statink_uploads:
|
||||
if not utils.custom_key_exists("force_uploads", CONFIG_DATA):
|
||||
print("Skipping already-uploaded battle.")
|
||||
continue
|
||||
to_upload.append(battle)
|
||||
|
||||
post_result(data_new, False, blackout, test_run, overview_data=overview_file) # one or multiple; monitoring mode = False
|
||||
post_result(to_upload, False, blackout, test_run, overview_data=overview_file) # one or multiple; monitoring mode = False
|
||||
sys.exit(0)
|
||||
|
||||
# regular run
|
||||
|
||||
6
utils.py
6
utils.py
@@ -64,7 +64,7 @@ def b64d(string):
|
||||
thing_id = thing_id.replace("CoopStage-", "")
|
||||
thing_id = thing_id.replace("CoopGrade-", "")
|
||||
if thing_id[:15] == "VsHistoryDetail" or thing_id[:17] == "CoopHistoryDetail":
|
||||
return thing_id[-36:] # uuid
|
||||
return thing_id # string
|
||||
else:
|
||||
return int(thing_id) # integer
|
||||
|
||||
@@ -99,6 +99,6 @@ def custom_key_exists(key, config_data, value=True):
|
||||
'''Checks if a given custom key exists in config.txt and is set to the specified value (true by default).'''
|
||||
|
||||
# https://github.com/frozenpandaman/s3s/wiki/config-keys
|
||||
if key not in ["ignore_private", "app_user_agent"]:
|
||||
print("(!) checking unexpected custom key")
|
||||
if key not in ["ignore_private", "app_user_agent", "force_uploads"]:
|
||||
print("(!) Checking unexpected custom key")
|
||||
return True if key in config_data and config_data[key].lower() == str(value).lower() else False
|
||||
|
||||
Reference in New Issue
Block a user