Try to use provided link for music, use youtube if it is a file:// link.
This commit is contained in:
parent
ff82089979
commit
7857d66376
@ -96,9 +96,12 @@ scrobble_music() {
|
|||||||
|
|
||||||
# Post music with -M flag requires playerctl.
|
# Post music with -M flag requires playerctl.
|
||||||
post_music() {
|
post_music() {
|
||||||
local text="[$(playerctl metadata -f 'Now playing "{{title}}" by "{{artist}}" from "{{album}}"')]"
|
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 link="$(playerctl metadata -f '{{xesam:url}}')"
|
||||||
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}')
|
if [[ "${link}" =~ ^file:// ]]; then
|
||||||
|
link="https://www.youtube.com/results?search_query=$(playerctl metadata -f '{{artist}} {{title}}' | urlencode -b)"
|
||||||
|
fi
|
||||||
|
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}')
|
||||||
local result
|
local result
|
||||||
result="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \
|
result="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \
|
||||||
-d "$json" \
|
-d "$json" \
|
||||||
|
Loading…
Reference in New Issue
Block a user