2012-03-31, 07:54
The song ratings are in the Music.db file. This really, really should be part of the exported data.
I had the same issue, plus I was using FLAC files, which have some issues regarding song ratings within a tag as far as XBMC is concerned. My solution was to write a script to extract that ratings info from the music.db file, and put them into a FLAC tag that XBMC will understand without issue. This might be useful for your purposes.
Note that my scripting abilities are not the best, but this might get you started to your own solution:
I'm sure someone with more talent than me can make this pretty, and adapt it for import/export of ratings data.
I had the same issue, plus I was using FLAC files, which have some issues regarding song ratings within a tag as far as XBMC is concerned. My solution was to write a script to extract that ratings info from the music.db file, and put them into a FLAC tag that XBMC will understand without issue. This might be useful for your purposes.
Note that my scripting abilities are not the best, but this might get you started to your own solution:
Code:
#!/bin/bash
DBDIR=/path/to/db/file
DBFILE=MyMusic7.db
MAINPATH=/needed this to address personal weirdnes
FLACDIR=/path/to/flacs
WORKDIR=/tmp/audio/
DELPATH="smb://SERVER/sharedir/"
#test for required software
command -v sqlite3 >/dev/null 2>&1 || { echo >&2 "I require sqlite3 but it's not installed. Aborting."; exit 1; }
command -v metaflac >/dev/null 2>&1 || { echo >&2 "I require metaflac but it's not installed. Aborting."; exit 1; }
#test for flac directory
if [ ! -d $FLACDIR ]
then
echo "I can't find flac files! exiting."
exit 1
fi
#test for Work directory
if [ ! -d $WORKDIR ]
then
echo "$WORKDIR does not exist, creating."
mkdir -p $WORKDIR
else
echo "Using existing $WORKDIR ..."
fi
# main loop start
sqlite3 $DBDIR$DBFILE "select rating,strPath,strFileName from song natural left outer join path where rating <> 0" | while read RECORD; do
echo "-------------------------------"
RATING=$(echo $RECORD | cut -d \| -f 1 )
RAWPATH=$(echo $RECORD | cut -d \| -f 2 )
SONGFILE=$(echo $RECORD | cut -d \| -f 3 )
SONGPATH=${RAWPATH#$DELPATH}
FULLPATH="$MAINPATH""$SONGPATH""$SONGFILE"
if [ ! -f "$FULLPATH" ]
then
echo "I couldn't find song files! Something is wrong!" $FULLPATH
fi
RAWEXRATING=`metaflac --show-tag=RATING "$FULLPATH"`
EXRATING=$(echo $RAWEXRATING | cut -d \= -f 2 )
if [ -z "$EXRATING" ]
then
EXRATING=0
fi
if [ "$EXRATING" -eq "$RATING" ]
then
echo "No change to song rating for "$FULLPATH
else
echo "Backing up $FULLPATH"
echo "to $FULLPATH.bak"
cp "$FULLPATH" "$FULLPATH.bak"
echo "Clearing out old song rating metadata..."
metaflac --remove-tag="RATING" "$FULLPATH"
echo "Current rating was "$EXRATING
echo "Rating now set to "$RATING
metaflac --set-tag="RATING=$RATING" "$FULLPATH"
fi
done
exit
I'm sure someone with more talent than me can make this pretty, and adapt it for import/export of ratings data.