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:
parent
661f00217c
commit
13aeccd78f
16
ratatoskr.sh
16
ratatoskr.sh
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user