text stringlengths 1 93.6k |
|---|
def __call__(self):
|
lineend = shutil.get_terminal_size()[0] - 5 # 5 = ('>=> ' or '===>') + blank 1
|
ika = '>=> ' if self.count % 2 == 0 else '===>'
|
sys.stdout.write(f"\r{' '*self.count}{ika}{' '*(lineend - self.count)}")
|
sys.stdout.flush()
|
self.count += 1
|
if self.count > lineend:
|
self.count = 0
|
def __del__(self):
|
sys.stdout.write(f"\r{' '*(shutil.get_terminal_size()[0] - 1)}\r")
|
sys.stdout.flush()
|
def export_seed_json(skipprefetch=False):
|
'''Export a JSON file for use with Lean's seed checker at https://leanny.github.io/splat3seedchecker/.'''
|
try:
|
import pymmh3 as mmh3
|
except ModuleNotFoundError:
|
print("This function requires a Python module you don't have installed. " \
|
"Please run " + '`\033[91m' + "pip install -r requirements.txt" + '\033[0m`' + " and try again.")
|
sys.exit(1)
|
if not skipprefetch:
|
prefetch_checks(printout=True)
|
sha = utils.translate_rid["MyOutfitCommonDataEquipmentsQuery"]
|
outfit_post = requests.post(iksm.GRAPHQL_URL, data=utils.gen_graphql_body(sha),
|
headers=headbutt(), cookies=dict(_gtoken=GTOKEN))
|
sha = utils.translate_rid["LatestBattleHistoriesQuery"]
|
history_post = requests.post(iksm.GRAPHQL_URL, data=utils.gen_graphql_body(sha),
|
headers=headbutt(), cookies=dict(_gtoken=GTOKEN))
|
if outfit_post.status_code != 200 or history_post.status_code != 200:
|
print("Could not reach SplatNet 3. Exiting.")
|
sys.exit(1)
|
try:
|
outfit = json.loads(outfit_post.text)
|
history = json.loads(history_post.text)
|
except:
|
print("Ill-formatted JSON file received. Exiting.")
|
sys.exit(1)
|
try:
|
pid = history["data"]["latestBattleHistories"]["historyGroupsOnlyFirst"]["nodes"][0]["historyDetails"]["nodes"][0]["player"]["id"]
|
# VsPlayer-u-<20 char long player id>:RECENT:<YYYYMMDD>T<HHMMSS>_<UUID>:u-<same player id as earlier>
|
s = utils.b64d(pid)
|
r = s.split(":")[-1]
|
except KeyError: # no recent battles (mr. grizz is pleased)
|
try:
|
sha = utils.translate_rid["CoopHistoryQuery"]
|
history_post = requests.post(iksm.GRAPHQL_URL, data=utils.gen_graphql_body(sha),
|
headers=headbutt(), cookies=dict(_gtoken=GTOKEN))
|
if history_post.status_code != 200:
|
print("Could not reach SplatNet 3. Exiting.")
|
sys.exit(1)
|
try:
|
history = json.loads(history_post.text)
|
except:
|
print("Ill-formatted JSON file received. Exiting.")
|
sys.exit(1)
|
pid = history["data"]["coopResult"]["historyGroupsOnlyFirst"]["nodes"][0]["historyDetails"]["nodes"][0]["id"]
|
# CoopHistoryDetail-u-<20 char long player id>:<YYYYMMDD>T<HHMMSS>_<UUID>
|
s = utils.b64d(pid)
|
r = s.split(":")[0].replace("CoopHistoryDetail-", "")
|
except KeyError:
|
r = ""
|
h = mmh3.hash(r)&0xFFFFFFFF # make positive
|
key = base64.b64encode(bytes([k^(h&0xFF) for k in bytes(r, "utf-8")]))
|
t = int(time.time())
|
with open(os.path.join(os.getcwd(), f"gear_{t}.json"), "x") as fout:
|
json.dump({"key": key.decode("utf-8"), "h": h, "timestamp": t, "gear": outfit}, fout)
|
print(f"gear_{t}.json has been exported.")
|
def parse_arguments():
|
'''Setup for command-line options.'''
|
parser = argparse.ArgumentParser()
|
srgroup = parser.add_mutually_exclusive_group()
|
parser.add_argument("-M", dest="N", required=False, nargs="?", action="store",
|
help="monitoring mode; pull data every N secs (default: 300)", const=300)
|
parser.add_argument("-m", dest="N", required=False, nargs="?", action="store",
|
help=argparse.SUPPRESS, const=300)
|
parser.add_argument("-r", required=False, action="store_true",
|
help="check for & upload battles/jobs missing from stat.ink")
|
srgroup.add_argument("-nsr", required=False, action="store_true",
|
help="do not check for Salmon Run jobs")
|
srgroup.add_argument("-osr", required=False, action="store_true",
|
help="only check for Salmon Run jobs")
|
parser.add_argument("--blackout", required=False, action="store_true",
|
help="remove player names from uploaded scoreboard data")
|
parser.add_argument("-o", required=False, action="store_true",
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.