09-23-2021, 11:06 AM
(09-23-2021, 08:18 AM)cprogrammer Wrote: 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.
Added to the TODO list for post 7.4.0 release.
Are the items below the UI elements that need to be visible for each track?
1. Song rating
- Number or row of Star icons?
- Range?
2. Play count
- Number or row of tick marks indicating popularity?
- Range
I see there is also a mechanism for uploading titles to last.fm/libre.fm. Are these services still popular?
-Tim