Created
February 23, 2024 11:59
-
-
Save aparatext/7aed8c047bdc65c306168b96a06a20be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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