Skip to content

Instantly share code, notes, and snippets.

@kadiwa4
Created April 28, 2023 14:18
Show Gist options
  • Select an option

  • Save kadiwa4/d58fb9a0b5fa609cf5ac62cf1973515d to your computer and use it in GitHub Desktop.

Select an option

Save kadiwa4/d58fb9a0b5fa609cf5ac62cf1973515d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
cd "$(dirname -- "$0")"
mkdir mods 2> /dev/null
cd mods
echo Creating download URL list...
download_urls="$(paste -d \0 <(perl -n -e '/^.+?"projectID":\s*(\d+)/ && print "https://www.curseforge.com/api/v1/mods/$1\n"' < ../manifest.json) <(perl -n -e '/^.+?"fileID":\s*(\d+)/ && print "/files/$1/download\n"' < ../manifest.json))"
echo Created download URL list
echo Downloading mods...
echo "$download_urls" | while read url
do
url="$(curl --tlsv1.2 -sSfI "$url" | perl -n -e '/location:\s*([^\r\n]+)/i && print "$1"')"
curl --proto "=https" --tlsv1.2 -sSfLO "$url"
done
echo Downloaded mods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment