Created
November 11, 2023 23:18
-
-
Save samba/d6e3e1b8bdbaa108b509860468e1f5a9 to your computer and use it in GitHub Desktop.
Batocera x86_64 download script
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
#!/bin/bash | |
ARCH="x86_64" | |
DOWNLOAD_URL_PAGE="https://batocera.org/download" | |
get_downloader () { | |
which -a curl wget | head -n 1 | |
} | |
read_url_cmd () { | |
DL=$(get_downloader) | |
case $(basename ${DL}) in | |
curl) echo ${DL} -L --continue-at - -S ${@} -o ;; | |
wget) echo ${DL} --max-redirect 10 --continue -q ${@} -O ;; | |
esac | |
} | |
get_download_path () { | |
eval "$(read_url_cmd ${DOWNLOAD_URL_PAGE}) -" | grep -oE "href=\"[^\"]*\"" | grep "${ARCH}" | grep "img.gz" \ | |
| sed 's/href="//; s/"$//;' | |
} | |
do_download () { | |
read url; | |
eval "$(read_url_cmd "${url}") $(basename "${url}")" | |
} | |
get_download_path | do_download |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment