get the direct url

This commit is contained in:
2026-06-13 16:14:37 +02:00
parent 76efd1a938
commit 9ce5b1ca57

View File

@@ -57,12 +57,11 @@ HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d') BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
# Parse the URL from the JSON response. # Parse the direct file URL from the JSON response.
# This assumes a response like {"url": "https://..."} # Expects a response containing a "file_url" field.
# You might need to adjust the regex or use jq depending on your API structure. URL=$(echo "$BODY" | grep -oP '"file_url"\s*:\s*"\K[^"]+')
URL=$(echo "$BODY" | grep -oP '"url"\s*:\s*"\K[^"]+')
# Fallback: if no URL field is found, just copy the whole body if it's a raw string # Fallback: if no file_url field is found, just copy the whole body if it's a raw string
if [ -z "$URL" ]; then if [ -z "$URL" ]; then
URL="$BODY" URL="$BODY"
fi fi