Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Song ratings
#30
It will not be difficult to support ratings. I use this in my setup and mpd supports this by enabling this in mpd.conf. The moment you put the sticker_file entry in mpd.conf, a sqlite table is created with the schema as below. You are free to use this sticker database for anything and not just rating.


Code:
$ grep sticker /etc/mpd.conf
sticker_file /var/lib/mpd/MDrive/data/sticker.db

$ sqlite3 /var/lib/mpd/MDrive/data/sticker.db
sqlite> .schema
CREATE TABLE sticker(  type VARCHAR NOT NULL,   uri VARCHAR NOT NULL,   name VARCHAR NOT NULL,   value VARCHAR NOT NULL);
CREATE UNIQUE INDEX sticker_value ON sticker(type, uri, name);
CREATE INDEX rating        on sticker(value);



Now to implement rating one can use the mpc sticker command. Let us say i have a song with a URI 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac'

The first command below will set the rating to 5. The second command will get the rating

Code:
$ mpc sticker 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac' set rating 5
$ mpc sticker 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac' get rating
rating=5

Now let us say I want to implement play counts and let us decide we will name this field as PlayCount. So this is what I will do


Code:
$ mpc sticker 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac' set PlayCount 1
$ mpc sticker 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac' get PlayCount
PlayCount=1
$ mpc sticker 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac' set PlayCount 4
$ mpc sticker 'Lobo 1971-2006 (flac)/1973 - Calumet - Rhino/15 - How Can I Tell Her (Early Version).flac' get PlayCount
PlayCount=4

The database is so flexible that you don't even require to pre-populate it. I have written a C program (called mpdev_update) using sqlite api to pre-populate this sqlite database and it takes less than 5 seconds to update around 60,000 songs first time. I'm also using a concept called 'karma'. All songs start with a karma of 50. When I don't like a song and I skip the song  and don't listen to more than 85% of the song, I decrease the karma of a song. When I play the same song multiple times, I increase the karma of a song. Over a period of time I have build a database of all my songs with play counts, last played, rating and karma and I use a simple shell which uses sqlite3 command to query this database an auto-generate various playlists just like itunes 'smart playlists'.

I would very much love to have this feature in moode. That will allow me to use moode from my smart phone to be able to rate songs. At the moment I am forced to use a laptop with cantata to be able to rate songs. Though Cantata is an excellent mpd player, it is no longer being maintained. Currently I use rompr on the smart phone to rate songs. But rompr doesn't use the sticker db. It uses it's own MySQL db. So what I do is have a daemon which updates rating from the MySQL db back to the sticker db (only records that change).

I also use a daemon that I wrote which connects to mpd on 6600 and uses the IDLE command and it updates an sqlite database for last played, playcount, etc and also scrobbles tracks to last.fm and libre.fm - MPD Event Watcher

EDIT: I forgot to add a feature of sticker db. A good thing about sticker is that mpd removes entries from the sticker db when you delete a song.
Reply


Messages In This Thread
Song ratings - by okneloper - 06-18-2020, 09:06 AM
RE: Song ratings - by TheOldPresbyope - 06-18-2020, 10:30 AM
RE: Song ratings - by okneloper - 06-18-2020, 01:14 PM
RE: Song ratings - by Tim Curtis - 06-18-2020, 01:17 PM
RE: Song ratings - by TheOldPresbyope - 06-18-2020, 01:39 PM
RE: Song ratings - by okneloper - 06-18-2020, 02:03 PM
RE: Song ratings - by Tim Curtis - 06-18-2020, 02:11 PM
RE: Song ratings - by TheOldPresbyope - 06-18-2020, 02:20 PM
RE: Song ratings - by okneloper - 06-18-2020, 05:31 PM
RE: Song ratings - by TheOldPresbyope - 06-18-2020, 06:17 PM
RE: Song ratings - by okneloper - 06-18-2020, 06:44 PM
RE: Song ratings - by Tim Curtis - 06-18-2020, 07:00 PM
RE: Song ratings - by okneloper - 06-18-2020, 07:16 PM
RE: Song ratings - by Tim Curtis - 06-18-2020, 07:19 PM
RE: Song ratings - by TheOldPresbyope - 06-18-2020, 07:51 PM
RE: Song ratings - by okneloper - 06-18-2020, 08:02 PM
RE: Song ratings - by okneloper - 06-18-2020, 09:20 PM
RE: Song ratings - by Tim Curtis - 06-18-2020, 09:57 PM
RE: Song ratings - by okneloper - 06-19-2020, 07:56 AM
RE: Song ratings - by Tim Curtis - 06-19-2020, 12:22 PM
RE: Song ratings - by okneloper - 06-19-2020, 12:47 PM
RE: Song ratings - by Tim Curtis - 06-19-2020, 01:21 PM
RE: Song ratings - by TheOldPresbyope - 06-19-2020, 01:52 PM
RE: Song ratings - by okneloper - 06-19-2020, 04:21 PM
RE: Song ratings - by TheOldPresbyope - 06-19-2020, 04:59 PM
RE: Song ratings - by CallMeMike - 06-20-2020, 07:35 AM
RE: Song ratings - by DRONE7 - 06-20-2020, 09:11 AM
RE: Song ratings - by okneloper - 06-20-2020, 09:11 PM
RE: Song ratings - by okneloper - 02-26-2021, 09:35 AM
RE: Song ratings - by cprogrammer - 09-23-2021, 08:18 AM
RE: Song ratings - by Tim Curtis - 09-23-2021, 11:06 AM
RE: Song ratings - by cprogrammer - 09-23-2021, 11:42 AM
RE: Song ratings - by TheOldPresbyope - 09-23-2021, 01:17 PM
RE: Song ratings - by Tim Curtis - 09-23-2021, 01:26 PM
RE: Song ratings - by stefsam - 12-24-2021, 11:38 AM

Forum Jump: