From 194ec452be9255604a21a918a7ae1442eb50b620 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Sun, 24 Dec 2023 02:00:39 -0600 Subject: [PATCH] Fix wget2 * Fix wget2 * Improve wget2 check * Use wget2 whenever available * Use curl instead of wget in order to check where URLs redirect --- quickget | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/quickget b/quickget index b06b6ca..ed9d570 100755 --- a/quickget +++ b/quickget @@ -963,6 +963,11 @@ function web_get() { exit 1 fi echo #Necessary as aria2c in suppressed mode does not have new lines + elif command -v wget2 &>/dev/null; then + if ! wget2 --quiet --continue --tries=3 --read-timeout=10 --force-progress --progress=bar:force:noscroll "${URL}" -O "${DIR}/${FILE}" "${HEADERS[@]}"; then + echo "ERROR! Failed to download ${URL} with wget2. Try running 'quickget' again." + exit 1 + fi elif ! wget --quiet --continue --tries=3 --read-timeout=10 --show-progress --progress=bar:force:noscroll "${URL}" -O "${DIR}/${FILE}" "${HEADERS[@]}"; then echo "ERROR! Failed to download ${URL} with wget. Try running 'quickget' again." exit 1 @@ -1266,8 +1271,8 @@ function get_archcraft() { local URL="" local TMPURL="" - TMPURL=$(wget -q -S -O- --max-redirect=0 "https://sourceforge.net/projects/archcraft/files/latest/download" 2>&1 | grep -i Location | cut -d' ' -f4) - URL=${TMPURL%\?*} + # Check where the URL redirects using curl. Output to a nonexistent directory so it's not possible to successfully download the image + URL=$(curl -Lfs "https://sourceforge.net/projects/archcraft/files/latest/download" -w %{url_effective} -o /this/is/a/nonexistent/directory/$RANDOM/$RANDOM) echo "${URL} ${HASH}" } @@ -1986,8 +1991,7 @@ function get_reactos() { local URL="" local TMPURL="" - TMPURL=$(wget -q -S -O- --max-redirect=0 "https://sourceforge.net/projects/reactos/files/latest/download" 2>&1 | grep -i Location | cut -d' ' -f4) - URL=${TMPURL%\?*} + URL=$(curl -Lfs "https://sourceforge.net/projects/reactos/files/latest/download" -w %{url_effective} -o /this/is/a/nonexistent/directory/$RANDOM/$RANDOM) echo "${URL} ${HASH}" } @@ -2256,8 +2260,7 @@ function get_zorin() { local ISO="" local URL="" - # Parse out the iso URL from the redirector - URL=$(wget -q -S -O- --max-redirect=0 "https://zrn.co/${RELEASE}${EDITION}" 2>&1 | grep Location | cut -d' ' -f4) + URL=$(curl -Lfs "https://zrn.co/${RELEASE}${EDITION}" -w %{url_effective} -o /this/is/a/nonexistent/directory/$RANDOM/$RANDOM) echo "${URL} ${HASH}" }