Browse Source

Use jq

Signed-off-by: fbt <fbt@fleshless.org>
master
Jack L. Frost 2 years ago
parent
commit
3a48f36d43
  1. 10
      ufw

10
ufw

@ -82,7 +82,7 @@ get_album_id() {
get_api_status <<< "$api_response"
if (( api_status == 200 )); then
album_id=$( jshon -e data -e album -e id -u <<< "$api_response" )
album_id=$( jq -r '.data.album.id' <<< "$api_response" )
misc_curl_args+=( -F album_id="$album_id" )
else
printf 'Error [album]: %s %s\n' "$api_status" "$api_status_message"
@ -162,7 +162,7 @@ upload() {
get_api_status <<< "$api_response"
if (( api_status == 200 )); then
file_link=$( jshon -e data -e "$file_url_request" -u <<< "$api_response" )
file_link=$( jq -r ".data.${file_url_request}" <<< "$api_response" )
(( flag_shortlink )) || {
(( flag_directlink )) || file_link="${file_link#*.}"
@ -188,7 +188,7 @@ get_shortlink() {
if (( api_status == 200 )); then
read -r short_url real_url < <(
jshon -e data -e short_url -u <<< "$api_response"
jq -r '.data.short_url' <<< "$api_response"
)
printf '%s\n' "$short_url"
@ -221,7 +221,7 @@ take_screenshot() {
get_api_status() {
read -d '' -r api_status api_status_message < <(
jshon -e status -e code -u -p -e message -u
jq -r '.status.code, .status.message'
)
if ! (( api_status == 200 )); then
@ -252,7 +252,7 @@ get_my_ip() {
get_api_status <<< "$api_response"
if (( api_status == 200 )); then
my_ip=$( jshon -e data -e ip -u <<< "$api_response" )
my_ip=$( jq -r '.data.ip' <<< "$api_response" )
printf '%s\n' "$my_ip"
else
printf 'Error: %s %s\n' "$api_status" "$api_status_message"

Loading…
Cancel
Save