So, I'm trying to download the latest release from GitHub using a Windows batch script. I can get a long list of URLs by running curl -s https://api.github.com/repos/ActualMandM/cemu_graphic_packs/releases/latest
, but I can't figure out how to pass the "browser_download_url": "https://github.com/ActualMandM/cemu_graphic_packs/releases/download/Github828/graphicPacks828.zip"
it outputs to curl. I've looked online, but everything I found was for PowerShell and most of them used wget.
CodePudding user response:
If you really want to use batch for this, you'll have to search the output JSON for the value you're looking for and then process that string. If the JSON had appeared all on one line, you'd need to take a different approach, but you got lucky.
for /f "tokens=1,* delims=:" %%A in ('curl -ks https://api.github.com/repos/ActualMandM/cemu_graphic_packs/releases/latest ^| find "browser_download_url"') do (
curl -kOL %%B
)
I've added the -k
flag because my computer requires it for some reason (so other peoples' might as well).
-O
will set the name of the output file to the remote output file name
-L
follows a redirect, which is required for downloading from Github.