Skip to content

Instantly share code, notes, and snippets.

@aparatext
Created February 23, 2024 11:59
Show Gist options
  • Select an option

  • Save aparatext/7aed8c047bdc65c306168b96a06a20be to your computer and use it in GitHub Desktop.

Select an option

Save aparatext/7aed8c047bdc65c306168b96a06a20be to your computer and use it in GitHub Desktop.
#!/usr/bin/env fish
set version_id (curl https://raw.githubusercontent.com/IntellectualSites/CurseForge-version-identifier/main/versions.json -s | jq '.[] | select(.name == "'$argv[2]'") | .id')
set mod_id (python3.12 -c 'import cloudscraper, sys; print(cloudscraper.create_scraper().get(f"https://legacy.curseforge.com/minecraft/mc-mods/{sys.argv[1]}").text)' $argv[1] | awk '
/<span>Project ID<\/span>/ {
getline
gsub(/<[^>]*>/, "", $0)
print $0
}' | string trim)
set mod_json (curl "https://www.curseforge.com/api/v1/mods/$mod_id/files?pageIndex=0&pageSize=5&sort=dateCreated&sortDescending=true&gameVersionId="$version_id"&removeAlphas=true" -s)
set download_url "https://mediafilez.forgecdn.net/files/"(echo $mod_json | jq '.data[0].id' | awk '{print substr($0, 1, length($0)-3) "/" substr($0, length($0)-2)}')"/"(echo $mod_json | jq '.data[0].fileName' -r)
echo $download_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment