Skip to content

Instantly share code, notes, and snippets.

@samba
Created November 11, 2023 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samba/d6e3e1b8bdbaa108b509860468e1f5a9 to your computer and use it in GitHub Desktop.
Save samba/d6e3e1b8bdbaa108b509860468e1f5a9 to your computer and use it in GitHub Desktop.
Batocera x86_64 download script
#!/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