Playing Auryo Soundcloud with MPD (cantata)

Share your own howto's etc. Not for support questions!

Playing Auryo Soundcloud with MPD (cantata)

Postby bester69 » 2019-12-09 23:49

Requirements:
- Cantata > 2.3.3(mpd)
- Auryo - Unofficial Soundcloud Desktop App: https://github.com/Superjo149/auryo/releases
- Playerctl - mpris command-line controller and library for spotify, vlc, audacious, bmp, cmus, and others.: https://github.com/altdesktop/playerctl/releases

>> We will compose soundcloud track within mpd server, by using playerctl Auryo-Metadata.

Image

----------------------------------

toggle.sh (KeyShorcut for Play/pause and Load soundcloud track within MPD (cantata))
Code: Select all
#!/bin/bash
#
export MPD_HOST=192.168.1.128
mpdauryo=/home/user/.mpd/mpdauryo.txt

#echo 1 > /tmp/mpdauryo.txt
touch $mpdauryo
mpdauryo=$(cat $mpdauryo)
if [ "$mpdauryo" -eq "1" ]
then
PID=$(pgrep "auryo")
if [ -z "$PID" ]
then
echo "nada"
else
if [ "$(playerctl --player=auryo_player status)" == "Paused" ]
then
:
else
echo "Toggle Auryo"
playerctl --player=auryo_player pause
/home/user/scripts/mpd_soundcloud.sh
exit
fi
fi

else
:
fi


 if [ "$mpdauryo" -eq "1" ]
then
:
else
PID=$(pgrep "auryo")
if [ -z "$PID" ]
then
echo "nada"
else
echo "Toggle Auryo"
if [ "$(playerctl --player=auryo_player status)" == "Stopped" ]
then
echo "nada"
playerctl --player=auryo_player play
exit
else
mpc pause
playerctl --player=auryo_player play-pause
  exit
fi
fi
fi

mpd &
mpc toggle &

 PID=$(pgrep "cantata")
if [ -z "$PID" ]
then
  if mpc status | grep playing >/dev/null      # If mpd is playing
then
 echo "playing"
   cantata &> /dev/null     
fi
else
  if mpc status | grep playing >/dev/null      # If mpd is playing
then
 echo "playing"
else
#killall cantata
:
fi
 fi


toggle_next.sh (KeyShorcut for Play/Load next soundcloud playlist track within MPD)
Code: Select all
#!/bin/bash
#
export MPD_HOST=192.168.1.128
MPDP=/home/user/.mpd
mpdauryo=/home/user/.mpd/mpdauryo.txt

#echo 1 > /tmp/mpdauryo.txt
touch $mpdauryo
mpdauryo=$(cat $mpdauryo)
 if [ "$mpdauryo" -eq "1" ]
then
PID=$(pgrep "auryo")
if [ -z "$PID" ]
then
echo "nada"
else
echo "Toggle Auryo"
playerctl --player=auryo_player next
/home/user/scripts/mpd_soundcloud.sh
playerctl --player=auryo_player pause
exit
fi
else
:
fi


 if [ "$mpdauryo" -eq "1" ]
then
:
else
# Auryo-player Next
PID=$(pgrep "auryo")
if [ -z "$PID" ]
then
echo "Toggle mpc"
else
echo "Toggle Auryo"
if [ "$(playerctl --player=auryo_player status)" == "Stopped" ]
then
echo "nada"
else
mpc pause
 playerctl --player=auryo_player next
  exit
fi
fi
fi

mpd &
mpc next
mpc play &

 PID=$(pgrep "cantata")
if [ -z "$PID" ]
then
  if mpc status | grep playing >/dev/null      # If mpd is playing
then
 echo "playing"
 cantata &> /dev/null
fi
 fi


mpd_soundcloud.sh (script that compose soundcloud track within mpd server)
Code: Select all
#!/bin/bash
#

export MPD_HOST=192.168.1.128
playpath="/home/user/.mpd/playlists/sound_temp.m3u"


clear
playerctl --player=auryo_player metadata

soun_title=$(playerctl --player=auryo_player metadata | grep "auryo_player xesam:title" | awk '{$1=$2=""; print $0}' | xargs -0)
soun_trackid=$(playerctl --player=auryo_player metadata | grep "auryo_player xesam:url" | awk '{print $3}' )
soun_length=$(playerctl --player=auryo_player metadata | grep "auryo_player mpris:length" | awk '{print $3}' )
soun_genre=$(playerctl --player=auryo_player metadata | grep "auryo_player xesam:genre" | awk '{$1=$2=""; print $0}' | xargs)
soun_artist=$(playerctl --player=auryo_player metadata | grep "auryo_player xesam:artist" | awk '{$1=$2=""; print $0}' | xargs)

soun_clientid="aaaaa-YourSoundClienID_Cantata_zzaaaass"
echo "$soun_title"
echo "$soun_trackid"
echo "$soun_length"
echo "$soun_genre"
echo "$soun_artist"


soun_uri="$soun_trackid/stream?client_id=$soun_clientid"
mpduri="$soun_uri#"
cadena="{\"album\":\"SoundCloud\",\"artist\":\"$soun_artist\",\"genre\":\"$soun_genre\",\"service\":\"soundcloud\",\"time\":\"3600\",\"title\":\"$soun_title\"}"
echo "$cadena"
mpduri="$mpduri$cadena"
echo "$mpduri" > "$playpath"
echo "$mpduri"
#
sfilename=$(basename "$playpath") && filename=${sfilename%.*}

mpc random off
mpc load $filename
# mpc next
# mpc play &
mpc play $(mpc playlist | wc -l) &
mpc random on

 PID=$(pgrep "cantata")
if [ -z "$PID" ]
then
  if mpc status | grep playing >/dev/null      # If mpd is playing
then
 echo "playing"
cantata &> /dev/null     
   
fi
else
  if mpc status | grep playing >/dev/null      # If mpd is playing
then
 echo "playing"
else
#killall cantata
:
fi
 fi


sauryo.sh (Scritpt for launching auryo with mpd mode):
- sauryo=1 : Play Auryo Soundcloud tracks within MPD
- sauryo=0 : Play Auryo Soundcloud tracks in desktop App.

Code: Select all
#!/bin/bash
#
mpdauryo=/home/user/.mpd/mpdauryo.txt


run() {
aur=$(pgrep -f /opt/Auryo/auryo)
#aur=$(pgrep -f /snap/auryo)
if [ -z "$aur" ]
then
#snap run auryo &> /dev/null  &
auryo &> /dev/null  &
fi
}

if [  -z "$1" ]
then
run
exit
fi

if [  "$1" -eq "1" ]
then
echo 1 > $mpdauryo
fi
if [  "$1" -eq "0" ]
then
echo 0 > $mpdauryo
fi
run
exit

bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1730
Joined: 2015-04-02 13:15

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable