mirror of
https://github.com/frozenpandaman/s3s.git
synced 2026-09-28 12:16:26 -05:00
Added progress (ika).
This commit is contained in:
22
s3s.py
22
s3s.py
@@ -207,7 +207,10 @@ def fetch_json(which, separate=False, exportall=False, specific=False, numbers_o
|
||||
queries.append(None)
|
||||
|
||||
needs_sorted = False # https://ygdp.yale.edu/phenomena/needs-washed :D
|
||||
progress = Progress()
|
||||
|
||||
for sha in queries:
|
||||
progress()
|
||||
if sha != None:
|
||||
if DEBUG:
|
||||
print(f"* making query1 to {sha}")
|
||||
@@ -222,6 +225,7 @@ def fetch_json(which, separate=False, exportall=False, specific=False, numbers_o
|
||||
for battle_group in query1_resp["data"]["latestBattleHistories"]["historyGroups"]["nodes"]:
|
||||
for battle in battle_group["historyDetails"]["nodes"]:
|
||||
battle_ids.append(battle["id"]) # don't filter out private battles here - do that in post_result()
|
||||
progress()
|
||||
|
||||
# ink battles - latest 50 turf war
|
||||
elif "regularBattleHistories" in query1_resp["data"]:
|
||||
@@ -229,12 +233,14 @@ def fetch_json(which, separate=False, exportall=False, specific=False, numbers_o
|
||||
for battle_group in query1_resp["data"]["regularBattleHistories"]["historyGroups"]["nodes"]:
|
||||
for battle in battle_group["historyDetails"]["nodes"]:
|
||||
battle_ids.append(battle["id"])
|
||||
progress()
|
||||
# ink battles - latest 50 anarchy battles
|
||||
elif "bankaraBattleHistories" in query1_resp["data"]:
|
||||
needs_sorted = True
|
||||
for battle_group in query1_resp["data"]["bankaraBattleHistories"]["historyGroups"]["nodes"]:
|
||||
for battle in battle_group["historyDetails"]["nodes"]:
|
||||
battle_ids.append(battle["id"])
|
||||
progress()
|
||||
# ink battles - latest 50 private battles
|
||||
elif "privateBattleHistories" in query1_resp["data"] \
|
||||
and not utils.custom_key_exists("ignore_private", CONFIG_DATA):
|
||||
@@ -242,11 +248,13 @@ def fetch_json(which, separate=False, exportall=False, specific=False, numbers_o
|
||||
for battle_group in query1_resp["data"]["privateBattleHistories"]["historyGroups"]["nodes"]:
|
||||
for battle in battle_group["historyDetails"]["nodes"]:
|
||||
battle_ids.append(battle["id"])
|
||||
progress()
|
||||
# salmon run jobs - latest 50
|
||||
elif "coopResult" in query1_resp["data"]:
|
||||
for shift in query1_resp["data"]["coopResult"]["historyGroups"]["nodes"]:
|
||||
for job in shift["historyDetails"]["nodes"]:
|
||||
job_ids.append(job["id"])
|
||||
progress()
|
||||
|
||||
if numbers_only:
|
||||
ink_list.extend(battle_ids)
|
||||
@@ -259,6 +267,7 @@ def fetch_json(which, separate=False, exportall=False, specific=False, numbers_o
|
||||
cookies=dict(_gtoken=GTOKEN))
|
||||
query2_resp_b = json.loads(query2_b.text)
|
||||
ink_list.append(query2_resp_b)
|
||||
progress()
|
||||
|
||||
for jid in job_ids:
|
||||
query2_j = requests.post(utils.GRAPHQL_URL,
|
||||
@@ -267,6 +276,7 @@ def fetch_json(which, separate=False, exportall=False, specific=False, numbers_o
|
||||
cookies=dict(_gtoken=GTOKEN))
|
||||
query2_resp_j = json.loads(query2_j.text)
|
||||
salmon_list.append(query2_resp_j)
|
||||
progress()
|
||||
|
||||
if needs_sorted: # put regular, bankara, and private in order, since they were exported in sequential chunks
|
||||
try:
|
||||
@@ -992,6 +1002,18 @@ def monitor_battles(which, secs, isblackout, istestrun):
|
||||
print("Please run s3s again with " + '\033[91m' + "-r" + '\033[0m' + " to get these battles.")
|
||||
print("Bye!")
|
||||
|
||||
class Progress:
|
||||
def __init__(self):
|
||||
self.count = 0
|
||||
|
||||
def __call__(self):
|
||||
lineend = 31
|
||||
ika = '>=> ' if self.count % 2 == 0 else '===>'
|
||||
sys.stdout.write("\r%s%s%s" % (' ' * self.count, ika, ' ' * (lineend - self.count)))
|
||||
sys.stdout.flush()
|
||||
self.count += 1
|
||||
if(self.count > lineend):
|
||||
self.count = 0
|
||||
|
||||
def main():
|
||||
'''Main process, including I/O and setup.'''
|
||||
|
||||
Reference in New Issue
Block a user