code cleanup
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
91a5d9bec2
commit
9b3516951c
56
ufw
56
ufw
|
@ -73,7 +73,29 @@ get_max_filesize() {
|
|||
fi
|
||||
}
|
||||
|
||||
get_album_id() {
|
||||
declare api_response api_status api_status_message
|
||||
|
||||
api_response=$( curl -fsL "$cfg_service_url/$cfg_api_path/album?a=new&name=$1&format=json&secret=$secret" )
|
||||
|
||||
get_api_status <<< "$api_response"
|
||||
|
||||
read -r api_status api_status_message < <(
|
||||
jshon -e status -e code -u -p -e message -u <<< "$api_response"
|
||||
)
|
||||
|
||||
if (( api_status == 200 )); then
|
||||
album_id=$( jshon -e data -e album -e id -u <<< "$api_response" )
|
||||
misc_curl_args+=( -F album_id="$album_id" )
|
||||
else
|
||||
printf 'Error [album]: %s %s\n' "$api_status" "$api_status_message"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
upload() {
|
||||
declare api_response api_status api_status_message
|
||||
|
||||
if (( flag_scrot )); then
|
||||
flag_rm=1
|
||||
file=$(take_screenshot) || { return 1; }
|
||||
|
@ -115,19 +137,7 @@ upload() {
|
|||
get_file_hash "$file"
|
||||
|
||||
if [[ "$album_name" ]]; then
|
||||
api_response=$( curl -fsL "$cfg_service_url/$cfg_api_path/album?a=new&name=$album_name&format=json&secret=$secret" )
|
||||
|
||||
read -r api_status api_status_message < <(
|
||||
jshon -e status -e code -u -p -e message -u <<< "$api_response"
|
||||
)
|
||||
|
||||
if (( api_status == 200 )); then
|
||||
album_id=$( jshon -e data -e album -e id -u <<< "$api_response" )
|
||||
misc_curl_args+=( -F album_id="$album_id" )
|
||||
else
|
||||
printf 'Error [album]: %s %s\n' "$api_status" "$api_status_message"
|
||||
return 1
|
||||
fi
|
||||
get_album_id "$album_name"
|
||||
fi
|
||||
|
||||
api_response=$( curl -sL \
|
||||
|
@ -140,10 +150,6 @@ upload() {
|
|||
-A 'zerofiles.org upload script' \
|
||||
"$cfg_service_url/$cfg_api_path/upload" )
|
||||
|
||||
read -r api_status api_status_message < <(
|
||||
jshon -e status -e code -u -p -e message -u <<< "$api_response"
|
||||
)
|
||||
|
||||
if (( flag_shortlink )); then
|
||||
if (( flag_directlink )); then
|
||||
file_url_request='short_url_direct'
|
||||
|
@ -158,6 +164,8 @@ upload() {
|
|||
fi
|
||||
fi
|
||||
|
||||
get_api_status <<< "$api_response"
|
||||
|
||||
if (( api_status == 200 )); then
|
||||
file_link=$( jshon -e data -e file -e "$file_url_request" -u <<< "$api_response" )
|
||||
|
||||
|
@ -178,9 +186,7 @@ get_shortlink() {
|
|||
|
||||
api_response=$( curl -sL "$cfg_service_url/$cfg_api_path/url?a=add&url=${url}&format=json&secret=$secret" )
|
||||
|
||||
read -r api_status api_status_message < <(
|
||||
jshon -e status -e code -u -p -e message -u <<< "$api_response"
|
||||
)
|
||||
get_api_status <<< "$api_response"
|
||||
|
||||
if (( api_status == 200 )); then
|
||||
read -r short_url real_url < <(
|
||||
|
@ -215,6 +221,12 @@ take_screenshot() {
|
|||
printf '%s\n' "$tmp_file"
|
||||
}
|
||||
|
||||
get_api_status() {
|
||||
read -r api_status api_status_message < <(
|
||||
jshon -e status -e code -u -p -e message -u
|
||||
)
|
||||
}
|
||||
|
||||
_mktemp() {
|
||||
declare tmp_file_name tmp_file_name_extra="$2" tmp_dir="$1"
|
||||
|
||||
|
@ -235,9 +247,7 @@ get_my_ip() {
|
|||
|
||||
api_response=$( curl -sl "$cfg_service_url/$cfg_api_path/ip?format=json" )
|
||||
|
||||
read -r api_status api_status_message < <(
|
||||
jshon -e status -e code -u -p -e message -u <<< "$api_response"
|
||||
)
|
||||
get_api_status <<< "$api_response"
|
||||
|
||||
if (( api_status == 200 )); then
|
||||
my_ip=$( jshon -e data -e ip -u <<< "$api_response" )
|
||||
|
|
Loading…
Reference in New Issue
Block a user