2019-10-30 23:37:49 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
TIDAL_HOST="http://localhost:47836"
|
|
|
|
|
|
|
|
function httpGet() {
|
|
|
|
curl -s "$TIDAL_HOST/$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
function httpSilentGet() {
|
|
|
|
curl -s -o /dev/null "$TIDAL_HOST/$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"play")
|
|
|
|
httpSilentGet play
|
|
|
|
;;
|
|
|
|
"pause")
|
|
|
|
httpSilentGet pause
|
|
|
|
;;
|
|
|
|
"playpause")
|
|
|
|
httpSilentGet playpause
|
|
|
|
;;
|
|
|
|
"next")
|
|
|
|
httpSilentGet next
|
|
|
|
;;
|
|
|
|
"previous")
|
|
|
|
httpSilentGet previous
|
|
|
|
;;
|
|
|
|
"info")
|
|
|
|
JSON=$(httpGet current)
|
|
|
|
TITLE=$(echo "$JSON" | jq -r '.title')
|
2023-05-14 11:26:34 +02:00
|
|
|
ARTISTS=$(echo "$JSON" | jq -r '.artists')
|
2019-10-30 23:37:49 +01:00
|
|
|
INFO=$(echo "$TITLE - $ARTISTS")
|
|
|
|
if [ ${#INFO} -le 3 ]; then
|
|
|
|
echo "No music info available"
|
|
|
|
else
|
|
|
|
echo "$INFO"
|
|
|
|
fi
|
|
|
|
;;
|
2023-03-09 10:21:15 +01:00
|
|
|
|
|
|
|
"songwhip")
|
|
|
|
JSON=$(httpGet current)
|
|
|
|
URL=$(echo "$JSON" | jq -r '.url')
|
|
|
|
|
|
|
|
WHIPPED_URL="https://songwhip.com$(curl -s -X POST 'https://songwhip.com/api/songwhip/create' -H 'Content-Type: application/json' --data-raw '{"url":"'"$URL"'","country":"NL"}' | jq -r '.data.item.url')"
|
|
|
|
echo "$WHIPPED_URL"
|
|
|
|
;;
|
2019-10-30 23:37:49 +01:00
|
|
|
"status")
|
|
|
|
if httpGet current | grep "paused" >/dev/null; then
|
|
|
|
echo "paused"
|
|
|
|
else
|
|
|
|
echo "playing"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "tidal-cli doesn't know this command"
|
|
|
|
;;
|
|
|
|
esac
|