MusicPlayerDaemon / mpc

Command-line client for MPD
GNU General Public License v2.0
191 stars 36 forks source link

Add ability to set the rating #15

Closed internethering closed 6 years ago

internethering commented 6 years ago

Hi,

I own a Korg Nanocontrol, which is perfect to control mpd (play, pause, next, ...). A litte bash script, aseqdump & mpc: https://paste.pound-python.org/show/TwdNe94LUzo4TejR0Dlc/ I would like to set the rating by the Nanocontrol too, may you add the ability to mpc? like: 'mpc rate [<0-5>]'

Greetings Richard

MaxKellermann commented 6 years ago

And what command is mpc supposed to send to MPD?

internethering commented 6 years ago

https://www.musicpd.org/doc/protocol/ says:

The Sticker Database

"Stickers" are pieces of information attached to songs. Some clients use them to store ratings and other volatile data.

I grepped the sourcecode of cantata, the file mpd-interface/mpdconnection.cpp provides functions like setRating(): "cmd+="sticker set song "+encodeName(f)+' '+constRatingSticker+' '+quote(val)+'\n';" and getRating(): "Response resp=sendCommand("sticker get song "+encodeName(file)+' '+constRatingSticker, false);

see also https://www.musicpd.org/doc/protocol/stickers.html

MaxKellermann commented 6 years ago

mpc already has the ability to set stickers since version 0.19, released in 2009.

internethering commented 6 years ago

nice. It isn't documented in the man page, so I asked here. For the protocol, to set 5-star rating, the command is:

mpc sticker "`mpc -f %file% current`" set rating 10