I think we have our first fully complete flag, -M should now post music and let you know if it was successful or if there were errors.

This commit is contained in:
stormdragon2976 2023-01-30 00:23:54 -05:00
parent 661f00217c
commit 13aeccd78f
1 changed files with 14 additions and 2 deletions

View File

@ -76,9 +76,21 @@ post_music() {
local text="[$(playerctl metadata -f 'Now playing "{{title}}" by "{{artist}}" from "{{album}}"')]"
local link="(https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b))"
local json=$(jq -n --arg status "$text$link" --arg spoiler_text "Music" --arg content_type "text/markdown" '{status: $status, spoiler_text: $spoiler_text, content_type: $content_type}')
curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \
local result
result="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \
-d "$json" \
"${instanceURL}/api/v1/statuses"
"${instanceURL}/api/v1/statuses")"
# Check for errors
if [[ $? -ne 0 ]]; then
echo "there was a problem contacting the server"
exit 1
fi
local error="$(echo "$result" | jq -r '.error')"
if [[ "$error" != "null" ]]; then
echo "Error: $error"
exit 1
fi
echo "Music posted!"
exit 0
}