Created attachment 149231 [details] Zip file containing audio files in different formats SUMMARY When I set ratings using the GUI, they are correctly stored in the files, using each file format’s rating system. For example, see the attached files (with no ratings). If I set the rating to 4/5 stars in the UI, the following information is saved in the files: m4a: 80 (Rating Percent) mp3: 196 (Popularimeter) ogg: 80 wma: 75 (Shared User Rating) If I reopen the files, they are all (correctly) shown was 4/5 stars in the UI. However, if I use the command-line to try to do the same thing, the rating mapping doesn’t work. And which ratings are saved depends on *how* I invoke kid3-cli: 1) separate command for each file, or 2) using filename wildcards. If I do: for i in *; do kid3-cli -c 'set Rating 80' $i; done I get the following in the UI: m4a: 4 stars mp3: 2 stars ogg: 4 stars wma: 80 (numeric value, no stars shown) If I instead do: kid3-cli -c 'set Rating 80' * I get the following the UI: m4a: 80 (Rating Information) mp3: 80 (Rating Information) ogg: 80 (RATING INFORMATION) wma: 80 (Rating Information) STEPS TO REPRODUCE 1. Unzip the attached file into an empty folder. 2. In this folder, type: for i in *; do kid3-cli -c 'set Rating 80' $i; done 3. Unzip the attached file into another folder. 4. In this second folder, type: kid3-cli -c 'set Rating 80' * OBSERVED RESULT See above. EXPECTED RESULT The two methods of invoking kid3-cli should result in the *same* ratings stored. And the ratings should correspond to 4/5 stars. (Though I’m not sure the ‘Rating’ field is the correct field to use, as the scale is ill-defined. Perhaps a new field called ‘Stars’ or ‘RatingStars’ could be added?) SOFTWARE/OS VERSIONS Operating System: openSUSE Tumbleweed 20220522 KDE Plasma Version: 5.24.5 KDE Frameworks Version: 5.94.0 Qt Version: 5.15.2 Kernel Version: 5.17.9-1-default (64-bit)
Created attachment 149232 [details] Zip file containing audio files in different formats Here’s an updated attachment (the last one had some metadata stored).
With the UI you can use "human readable" stars to set the rating, or if you want to do it on the low level, use the edit dialog to set the number explicitly. With kid3-cli, the star ratings do not seem to be supported, and setting a low level value on multiple files with different formats will probably not make a lot of sense since the mapping is different for the different formats. So I think that it would be best to support something like kid3-cli -c "set rating '***'" file.mp3 whereas using number would still provide the current low-level interface. What do you think?
> So I think that it would be best to support something like > > kid3-cli -c "set rating '***'" file.mp3 > > whereas using number would still provide the current low-level interface. > What do you think? Yes, I think that could work. But I think it’s a bit strange that the stars have to be quoted, so I would prefer: kid3-cli -c 'set rating ***' file.mp3 Also, this syntax can’t support half-stars (e.g., 3.5 stars), which is supported in some media players. (It is also used in the KDE rating system, e.g., shown in Dolphin, though this currently doesn’t read rating tags from audio files.) So I think a cleaner implementation would be: kid3-cli -c 'set stars 3' file.mp3 or kid3-cli -c 'set ratingstars 3' file.mp3 and where one can use half-stars: kid3-cli -c 'set ratingstars 3.5' file.mp3 (And this should give an error for invalid rating star values.)
You can find a development snapshot Kid3 git20220528 in https://sourceforge.net/projects/kid3/files/kid3/development/ where I have implemented 'get ratingstars' and 'set ratingstars' for kid3-cli. Note however, that not all your whishes come true: - You still can only set full stars, not half stars or other fractions. If you need it more fine grained, you can still set the internal values using 'set rating <internal-value>'. - If you use `kid3-cli -c "set ratingstars 2" *` this will not work correctly when files with different tag formats are included by `*`. The reason is by design: When a frame is added or edited on multiple files, it is only created once and then pasted into the remaining files, so this will only work when using ratingstars with files having the same tag format. In other cases, you should write the tags separately, e.g. using `for i in *; do kid3-cli -c 'set ratingstars 2' $i; done`.
(In reply to Urs Fleisch from comment #4) > You can find a development snapshot Kid3 git20220528 in > https://sourceforge.net/projects/kid3/files/kid3/development/ where I have > implemented 'get ratingstars' and 'set ratingstars' for kid3-cli. Thanks, I’ll take a look. BTW, is there a reason this update isn’t available at https://invent.kde.org/multimedia/kid3? > - You still can only set full stars, not half stars or other fractions. That’s OK for me. :) > - If you use `kid3-cli -c "set ratingstars 2" *` this will not work > correctly when files with different tag formats are included by `*`. The > reason is by design: When a frame is added or edited on multiple files, it > is only created once and then pasted into the remaining files, so this will > only work when using ratingstars with files having the same tag format. In > other cases, you should write the tags separately, e.g. using `for i in *; > do kid3-cli -c 'set ratingstars 2' $i; done`. OK. But I think this is very surprising behaviour, so shouldn’t it be mentioned in the documentation?
> Thanks, I'll take a look. BTW, is there a reason this update isn't available at https://invent.kde.org/multimedia/kid3? There is a new feature for BUG 451787 in my devel branch https://invent.kde.org/ufleisch/kid3/-/commits/devel, and it does not seem to work for its reporter at the moment, so I did not merge it into master. Since I wanted that feature (MP4 chapters) to be included in the latest development snapshot, the fix for this bug is also in the devel branch. The devel branch will be merged into master when the situation about BUG 451787 is clear. > OK. But I think this is very surprising behaviour, so shouldn't it be mentioned in the documentation? I will mention this in the section about 'set ratingstars'.
I’ve now done some testing, for various audio formats. Setting and getting a 1–5 star rating seems to work fine. Retrieving the ‘rating’ also seems to return the correct numerical rating for each format. But using the binary from https://sourceforge.net/projects/kid3/files/kid3/development/kid3-git20220528-win32-x64.zip/download, I get an error message when I try to set a rating on the .ogg file: /path/kid3-git20220528-Linux/kid3-cli: symbol lookup error: /path/kid3-git20220528-Linux/plugins/liboggflacmetadata.so: undefined symbol: __pow_finite (A similar .opus file works fine.) Also, I think trying to set an invalid star rating (e.g. ‘3.7’, ‘-1’, 6 or ‘foo’) should result in an error message (and no stored rating). Currently, it doesn’t. I’m not sure how *getting* an non-numerical rating (e.g., ‘foo’) as a ‘ratingstars’ value should be handled. Perhaps returning an empty value? Currently, the stored value (e.g., ‘foo’ for most formats, 0 for some) is returned.
Thanks for testing. I have now added validation for setting the value (version git20220531). I could reproduce the __pow_finite issue and it does not seem to happen now after a complete rebuild, but I do not have an explanation why this happened because my build environment is stable and always using the same Docker container.
Git commit 70dbaaa264a65dc85fe4e7ff3551cbd0acb144dd by Urs Fleisch. Committed on 04/06/2022 at 04:51. Pushed by ufleisch into branch 'master'. kid3-cli: Support star ratings with 'get/set ratingstars' M +18 -0 doc/en/index.docbook M +103 -1 src/core/model/kid3application.cpp M +4 -1 src/core/tags/frame.cpp https://invent.kde.org/multimedia/kid3/commit/70dbaaa264a65dc85fe4e7ff3551cbd0acb144dd