Skip to content

Instantly share code, notes, and snippets.

@MarkTiedemann
Last active March 9, 2023 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkTiedemann/d90bfd8134bb13695137f46f248db22e to your computer and use it in GitHub Desktop.
Save MarkTiedemann/d90bfd8134bb13695137f46f248db22e to your computer and use it in GitHub Desktop.
Direct Strike Leaderboard API
@echo off
setlocal enabledelayedexpansion
if not exist %~dp0timeit.exe (
curl -Lo %~dp0timeit.exe https://github.com/MarkTiedemann/rktools2k3/raw/master/timeit.exe
)
if not exist %~dp0jq.exe (
curl -Lo %~dp0jq.exe https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe
)
echo.
for /f "tokens=2,6,8,14 delims=:,}" %%a in ('%~dp0timeit.exe curl "https://api.wc3stats.com/leaderboard?map=Direct%%20Strike%%20Reforged&season=Season%%204&search=%1" 2^> nul ^| %~dp0jq -c ".body[]"') do (
set "name=%%a"
set "name=!name:~1,-1!"
for /f "tokens=1 delims=#" %%n in ("!name!") do (
echo #%%d %%n %%b / %%c
)
)
echo.
for /f "skip=2 tokens=3" %%t in ('%~dp0timeit.exe -t 2^>^&1') do (
set "time=%%t"
for /f "tokens=3 delims=:" %%s in ("!time!") do (
set "seconds=%%s"
set "seconds=!seconds:~1,-2!"
echo in !seconds!s
)
)
del timeit.dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment