Last active
March 28, 2024 03:53
-
-
Save devnoot/e86585ad3418c3ea23dd8e939a519eb3 to your computer and use it in GitHub Desktop.
Shell script to download all wad files from `levels/doom2` (or whichever path you choose) using the idgames archive API. Requires `jq` and `curl`
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
# Settings | |
API_URL=https://doomworld.com/idgames/api/api.php | |
MIRROR_URL=https://youfailit.net/pub/idgames/ | |
# Get directories | |
echo "Getting directories from API" | |
curl -s "$API_URL?action=getdirs&name=levels/doom2/&out=json" | jq '.content.dir[].name' > paths.txt | |
sed -i 's/"//g' paths.txt | |
# Aggregate the wad URLs | |
echo "Getting files in each directory from API" | |
while IFS= read -r line | |
do | |
URL="$API_URL?action=getcontents&name=$line&out=json" | |
curl -s $URL | jq '.content.file[].idgamesurl' >> wads.txt | |
done < paths.txt | |
# Create the URLs | |
sed -i "s|idgames://|$MIRROR_URL|g" wads.txt | |
sed -i "s|"|g" wads.txt | |
# Download the files | |
while IFS= read -r line | |
do | |
echo "Downloading $line" | |
curl -# -O "$line" | |
done < wads.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment