Closed antheas closed 3 years ago
Looked over the code (tagreader.cpp) and saw ratings are drawn from FMPS_RATING. By googling it I found the following article.
https://getmusicbee.com/forum/index.php?topic=18995.0
Previously I was using MusicBee as well, but did not find someone else with the same issue before googling the term. I guess I'm not the only one, so it's good this issue exists.
I will close the issue in a couple days in the hopes someone will post a solution. If not, I will post the solution I will have found.
Here's a little python script that uses the cli of kid3 to write the fmpt_rating tag alongside the rating tag generated from Musicbee and friends ("rating": 0-100 to "fmps_rating": 0-1). You can easily adapt it to fit your situation by modifying the math and tag names.
To use, install kid3 and place it in your path (should be done automatically in linux), as well as python 3. Then run with python3 sync_script.py "<your music dir>"
. The script should work in windows as well, but it's untested.
The script loads the values from the tags rating, fmps_rating, compares them and if they are different writes the value of "rating" to "fmps_rating". If they are the same it skips it. Change RATING_TO_FMPS = True
to False
to transfer the values of fmps_rating to rating instead (untested).
You should backup your library first and try it on an album you don't like to see if it works (by using Kid3 and Clementine). If it does you can proceed to the full library. Speed is around 1 song/sec on an ssd so it will take a while. It could definitely be faster, perhaps by consolidating the 2 read commands. I tried it but if a tag is missing kid3 will return only one value with no carriage return so you don't know from which tag it is.
Also, someone forgot to turn debug off when they compiled kid3 for my distro, which produces an output text in stderr every time kid3-cli runs, which I muted in the code below. If the code doesn't work remove the stderr
argument from the check_output
commands to view the full error.
#!/usr/bin/env python3
import os
import sys
import subprocess
import glob
# Choose which tag set will be modified (the index of the vorbis one in kid3)
TAG_TARGET = "2"
# Change the sync direction
RATING_TO_FMPS = True
EXT = "flac"
def sync_ratings(dirpath):
for fn in glob.glob(os.path.join(dirpath, "**/*.%s" % EXT), recursive=True):
name = fn
rating = subprocess.check_output([
'kid3-cli', '-c', 'get rating %s' % TAG_TARGET, fn], stderr=subprocess.DEVNULL).strip()
fmps = subprocess.check_output([
'kid3-cli', '-c', 'get fmps_rating %s' % TAG_TARGET, fn], stderr=subprocess.DEVNULL).strip()
try:
rating = int(rating) if not rating == b"" else 0
fmps = float(fmps) if not fmps == b"" else 0
fmps_int = int(fmps * 100)
except:
print("File \"%s\" has invalid ratings" % name)
continue
if rating == fmps_int:
continue
if RATING_TO_FMPS:
if rating == 100:
new_fmps = "1"
elif rating == 0:
new_fmps = "0"
else:
new_fmps = "%.1f" % (rating / 100)
print("%30s: syncing rating %3d to fmps %s from %.1f" %
(name, rating, new_fmps, fmps))
subprocess.check_output([
'kid3-cli', '-c', 'set fmps_rating %s %s' % (new_fmps, TAG_TARGET),
fn], stderr=subprocess.DEVNULL)
else:
new_rating = "%d" % int(fmps * 100)
print("%30s: syncing fmps %.1f to rating %s from %d" %
(name, fmps, new_rating, rating))
subprocess.check_output([
'kid3-cli', '-c', 'set rating %s %s' % (new_fmps, TAG_TARGET),
fn], stderr=subprocess.DEVNULL)
if __name__ == '__main__':
sync_ratings(sys.argv[1])
Before posting
Please follow the steps below and check the boxes with [x] once you did the step.
System information
Please provide information about your system and the version of Clementine used.
Expected behaviour / actual behaviour
I have a library of FLAC files and MP3s. MP3s have ID3v2.3.0 tags, with a Rating tag that ranges from 0-100. Their rating loads fine. The FLAC files have Vorbis tags, with the same rating format, but when they load they appear to have 0 stars. Edit track information shows 0 stars as well.
I tried editing the rating in the metadata of a FLAC file with the "Music Library > Save ratings..." on and it didn't save the new rating. (I didn't try it with an mp3 so perhaps this is the expected behavior)
Steps to reproduce the problem (only for bugs)
Load a FLAC file with a rating on it, it will appear as if it has 0 stars. I can provide one of my flac files if it is not reproducible.