some more cleanup

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
2026-11-28 03:13:00 +00:00
parent 31b5fb94c8
commit 59816295c5
+12 -8
View File
@@ -94,7 +94,7 @@ get_album_id() {
return 1 return 1
} }
get_api_status <<< "$api_response" get_api_status <<< "$api_response" || return 1
if (( api_status == 200 )); then if (( api_status == 200 )); then
album_id=$( jq -r '.data.album.id' <<< "$api_response" ) album_id=$( jq -r '.data.album.id' <<< "$api_response" )
@@ -184,7 +184,7 @@ upload() {
file_url_request='url' file_url_request='url'
fi fi
get_api_status <<< "$api_response" get_api_status <<< "$api_response" || return 1
if (( api_status == 200 )); then if (( api_status == 200 )); then
file_link=$( jq -r ".data.${file_url_request}" <<< "$api_response" ) file_link=$( jq -r ".data.${file_url_request}" <<< "$api_response" )
@@ -223,7 +223,7 @@ get_shortlink() {
return 1 return 1
} }
get_api_status <<< "$api_response" get_api_status <<< "$api_response" || return 1
if (( api_status == 200 )); then if (( api_status == 200 )); then
read -r short_url < <( read -r short_url < <(
@@ -243,13 +243,17 @@ get_api_status() {
jq -r '.status.code, .status.message' jq -r '.status.code, .status.message'
) )
if ! [[ $api_status ]]; then printf -v _ '%d' "$api_status" || {
err "Got invalid status from the api: $api_status"
return 1 return 1
fi }
if (( api_status >= 400 )); then (( api_status >= 400 )) && {
err "Error: $api_status, $api_status_message"
return 1 return 1
fi }
return 0
} }
_mktemp() { _mktemp() {
@@ -276,7 +280,7 @@ get_my_ip() {
return 1 return 1
} }
get_api_status <<< "$api_response" get_api_status <<< "$api_response" || return 1
if (( api_status == 200 )); then if (( api_status == 200 )); then
my_ip=$( jq -r '.data.ip' <<< "$api_response" ) my_ip=$( jq -r '.data.ip' <<< "$api_response" )