Created
September 23, 2023 18:35
-
-
Save ManicJamie/1e6972eef135e07bb2e1417b76626aeb to your computer and use it in GitHub Desktop.
GetTimes.py 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from speedruncompy.endpoints import * | |
from speedruncompy.enums import obsoleteFilter | |
import csv | |
from datetime import date | |
game_id = "76rqmld8" | |
""" | |
# Uncomment this area to get game by name | |
game_name = input("Enter game name:") | |
game = GetSearch(query=game_name, includeGames=True).perform()["gameList"][0] | |
game_id = game["id"] | |
""" | |
gameData = GetGameData(gameId=game_id).perform() | |
counts: list[dict] = gameData["runCounts"] | |
categories = [] | |
counts = sorted(counts, key=lambda x: x["count"], reverse=True) # sort in descending order | |
data = [] | |
with open("output.csv", "w") as f: | |
writer = csv.writer(f) | |
writer.writerow([f"{game_id} released {date.fromtimestamp(gameData['game']['releaseDate'])}"]) | |
writer.writerow(["Category ID", "Subcat Var ID", "Subcat Value ID", "Run ID", "Time", "Date Submitted"]) | |
for countData in counts: | |
categoryId = countData["categoryId"] | |
varId = countData["variableId"] | |
valId = countData["valueId"] | |
runs: list[dict] = GetGameLeaderboard2(gameId=game_id, categoryId=categoryId, | |
values=[{"variableId": varId, "valueIds": [valId]}], | |
obsolete=obsoleteFilter.SHOWN).perform_all()["runList"] | |
for run in runs: | |
time = run.get("time") | |
if time is None: | |
time = run.get("timeWithLoads") # guard against categories not using game's primary time | |
writer.writerow([categoryId, varId, valId, run["id"], run.get("time"), date.fromtimestamp(run["dateSubmitted"])]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses speedruncompy v0.0.5 (py >=3.11)