Hi all,
I've been using mocp for {4 years now, free}, and I think it's about time to give sth back to the community. So, I've tried to make moc capable of handling song ratings. Doing it right requires a few important decisions to be made; so far, I hacked together the smallest functionality that made sense to me. Ratings cannot (yet) be written to files, thus resolving the dilemma where to store them:)
Have a good one,
Adrian Lancucki
Patch (made against 2.5.0-beta1 revision 2526): http://pastebin.com/5J8LvY6J
Some eyecandy
Background
Different players handle ratings differently. They might either store the ratings in a local db (Amarok, iTunes, Banshee, Quodlibet), write it to audio files (Banshee, Windows Media Player) or pretend that they don't exist (foobar2000, Rhythmbox?, AIMP?).
Then there's the issue of how the ratings can be stored; AFAIK, some popular formats handle it differently:
- id3v1 - no ratings
- id3v2 - usually POPM frames indexed with e-mail/id (can be multiple per 1 file) with rating uint8 field 0-255, some players (foobar2k ratings plugin) use custom TXXX frames
- apev1/apev2 - no ratings
- vorbis comments - no official key for ratings, though some players (Banshee, Quodlibet) store something like "rating:quodlibet@foo.com=1.0" with ratings being 0.0-1.0 floats
Ratings patch
The good:
* it works:)
* ratings are stored in the cache
The bad:
* ratings are read-only
* they don't work with the ffmpeg plugin (I had a look at the sources and I'm pretty sure that libavformat can't handle POPM frames)
* the pretty star symbol I have used is utf8 and comes out garbled and breaks the layout on non-utf8 terminals
* ratings are not being stored in the playlist (.m3u doesn't handle ratings as #EXTINF)
I have patched the following plugins: aac, mp3, flac and vorbis. aac and mp3 both use libid3tag, so I'm using the first POPM frame available, mapping the values 0-255 to 0-5 stars the same way Banshee does
As for flac and vorbis, again similarly to Banshee, the pseudo-key "rating:banshee@foo=1.0" is being leveraged, mapping 0.0-1.0 to 0-255 (by multiplying by 255).
How to use it
1. Apply the patch.
2. Set "ShowRating = yes" in the config.
3. rm .moc/cache/tags.db
4. Make sure that ffmpeg is not the default plugin (by setting something like mp3(mp3):flac(flac):ogg(vorbis):" in the config file.
Having mocp store the ratings in db does a little sense to me, since it's not a portable solution. For now, I would suggest rating the songs elsewhere (Banshee or cmdline tools).
TODO
I'm not really sure how to check if the terminal supports utf8; if it's not, then the pretty star should be replaced with ugly "*".
Also, it would look nice if there was a new set of "theme" attributes for the rating stars only.
Make the ffmpeg plugin read the tags with libid3tag ?