Skip to content

Instantly share code, notes, and snippets.

@ManicJamie
Created September 23, 2023 18:35
Show Gist options
  • Save ManicJamie/1e6972eef135e07bb2e1417b76626aeb to your computer and use it in GitHub Desktop.
Save ManicJamie/1e6972eef135e07bb2e1417b76626aeb to your computer and use it in GitHub Desktop.
GetTimes.py 2
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"])])
@ManicJamie
Copy link
Author

Uses speedruncompy v0.0.5 (py >=3.11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment