Mpd on MoodeAudio: command for add current song to playlist ??? Help !!!

Need help with MPD?
Post Reply
neuronestanco
Posts: 3
Joined: March 16th, 2021, 7:11 pm

Mpd on MoodeAudio: command for add current song to playlist ??? Help !!!

Post by neuronestanco »

Hello everybody. I'm new to the forum. I ask for your help. I use MoodeAudio to play music from Raspberry; I configured lirc to use MoodeAudio with an IR remote, and I was able to configure all the mpd commands I needed on the remote buttons, except one function. I would like to add the song playing to the favorite playlist or to a playlist of my choice, so I ask you if there is an mpd or mpc command to do this and what is the correct syntax to insert in the lircrc file; if you need a script, could someone please help me on how should be the correct syntax with mpd? thank you so much
max
Forum team
Posts: 1236
Joined: January 15th, 2013, 3:43 pm

Re: Mpd on MoodeAudio: command for add current song to playlist ??? Help !!!

Post by max »

mpc has no command to add something to a stored playlist. Adding this feature would be easy if you know some C. MPD has commands to do it, and libmpdclient (the C library used by mpc) has it as well - it just needs to be wired to a mpc command.
But you could also write a small Python script to do it.
neuronestanco
Posts: 3
Joined: March 16th, 2021, 7:11 pm

Re: Mpd on MoodeAudio: command for add current song to playlist ??? Help !!!

Post by neuronestanco »

Thanks for your answer! Please could you help me on how to write a script to do this, which is to add the current song to a playlist??? ... Sorry but I'm self-taught and I'm trying to learn but for now it's very difficult! I can only ask for help from those who are capable
max
Forum team
Posts: 1236
Joined: January 15th, 2013, 3:43 pm

Re: Mpd on MoodeAudio: command for add current song to playlist ??? Help !!!

Post by max »

You could use Python-MPD2: https://python-mpd2.readthedocs.io/en/latest/

from mpd import MPDClient
client = MPDClient()
client.connect("localhost", 6600)
song = client.currentsong()
if song: client.playlistadd('the_playlist_name', song['file'])

Simple, isn't it?
neuronestanco
Posts: 3
Joined: March 16th, 2021, 7:11 pm

Re: Mpd su MoodeAudio: comando per aggiungere il brano corrente alla playlist ??? Guida!!!

Post by neuronestanco »

max wrote: March 17th, 2021, 5:25 am You could use Python-MPD2: https://python-mpd2.readthedocs.io/en/latest/

from mpd import MPDClient
client = MPDClient()
client.connect("localhost", 6600)
song = client.currentsong()
if song: client.playlistadd('the_playlist_name', song['file'])

Simple, isn't it?
I thank you Max for your availability, as I told you I am only self-taught and even the simplest things at this moment seem the most difficult ... so it is enough that with the nano command from ssh connected to moodeaudio, I copy everything you wrote, replacing only the name of the playlist, inside a script like "addsong.sh" and then in the .lircrc file to the combination of keys chosen by me on the remote control I recall the script by inserting its path? correct or did I forget something? do I have to add more syntax to your script that maybe it is obvious that there is but that I don't know? I ask you to have a little more patience please! :oops:
max
Forum team
Posts: 1236
Joined: January 15th, 2013, 3:43 pm

Re: Mpd on MoodeAudio: command for add current song to playlist ??? Help !!!

Post by max »

As I already said, this is Python, not Shell.
Post Reply