From 57193b0f59f8ccb1037fda6b0b5bebc6f7be7ca0 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 20 Dec 2024 18:32:26 +0100 Subject: [PATCH] fix: Follow download redirects (#981) --- src/mido.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mido.sh b/src/mido.sh index e03c9f52d..12c7709c0 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -635,6 +635,21 @@ getMG() { return 1 fi + local domain="buzzheavier.com" + + if [[ "$result" = *"$domain"* ]]; then + result=$(curl --silent --max-time 30 --request GET --user-agent "$user_agent" --referer "$result" --head --proto =https --tlsv1.2 --http1.1 -- "$result/download") || { + handle_curl_error "$?" "$domain" + return $? + } + result=$(echo "$result" | grep -i -m 1 "hx-redirect:") + if [ -z "$result" ]; then + error "Failed to extract redirect location! Please report this at $SUPPORT/issues." + return 1 + fi + result="https://${domain}${result:13}" + fi + MG_URL="$result" return 0 }