menu
I’ll be there when you fall
And they’ll be no pain at all
And I’ll be your shelter...
Your shelter from the storm
Copy rating from GoneMad Media Player on Android to Amarok 1.4
Short BASH script, modified version of the one I created for MediaMonkey. It has even more limitations than before - your files in the memorycard must be named /Music Downloads/$title by $artist.xxx, it will not work with filenames containing ! | ", maybe other characters.
Also, there's no way to tell apart songs saved in cue, you will get nothing or error of some kind. Whoever fixes those issues, please send me e-mail.
Exported stats file from tablet should be in /mnt/ftp/matrixx/stats.xml - edit the script to open your file.
function gonemad2amarok { sed -r -e 's|.+</Version>||' -e 's|</File>|\n|g' < /mnt/ftp/matrixx/stats.xml | grep -v '/storage/emulated/0/' | sed -r -e 's|<[^>]+>| |g' -e 's|/storage/sdcard1/Music Downloads/||g' -e 's/([0-5].[05]).+/\1/g' -e 's/ +//' -e 's/([a-z0-9)]) by ([A-Z0-9])/\1|\2/' -e 's/\..{3,4} /|/' | grep -v 0.0$ | head -n-1 | while read line
do
title="`echo $line | cut -f1 -d\|`"
artist="`echo $line | cut -f2 -d\|`"
rating="`echo $line \* 2 | cut -f3 -d\| | bc | sed s/\.0//`"
url="`sqlite3 ~/.kde/share/apps/amarok/collection.db 'select tags.url FROM tags JOIN artist ON tags.artist=artist.id WHERE tags.title="'"$title"'" AND artist.name="'"$artist"'";' `"
echo " "$title by $artist has new rating $rating -- $ret
sqlite3 ~/.kde/share/apps/amarok/collection.db 'UPDATE statistics SET rating='"$rating"' WHERE url="'"$url"'"'
let ret++
done
echo -e "\nRatings hopefully copied to amarok\n"
}
The second version: modified to use following filename schema:
/Music Downloads/$artist/%year - %album/%track. %title.xxx
function gonemad2amarok {
sed -r -e 's|.+</Version>||' -e 's|</File>|\n|g' < /mnt/ftp/matrixx/stats.xml | grep -v '/storage/emulated/0/' | sed -r -e 's|<[^>]+>| |g' -e 's|/storage/sdcard1/Music Downloads/||g' -e 's/([0-5]\.[05]).+/\1/g' -e 's/ +//' -e 's^([A-Za-z0-9 )])/.+/[0-9]{2}\.\ ([A-Za-z0-9 ])^\1|\2^' -e 's/\..{3,4} /|/'| grep -v 0.0$ | head -n-1 | while read line
do
title="`echo $line | cut -f2 -d\|`"
artist="`echo $line | cut -f1 -d\|`"
rating="`echo $line \* 2 | cut -f3 -d\| | bc | sed s/\.0//`"
url="`sqlite3 ~/.kde/share/apps/amarok/collection.db 'select tags.url FROM tags JOIN artist ON tags.artist=artist.id WHERE tags.title="'"$title"'" AND artist.name="'"$artist"'";' `"
echo " "$title by $artist has new rating $rating -- $ret
sqlite3 ~/.kde/share/apps/amarok/collection.db 'UPDATE statistics SET rating='"$rating"' WHERE url="'"$url"'"'
let ret++
done
echo -e "\nRatings hopefully copied to amarok\n"
}
usage: Backup statistics in GMMP -> Settings -> Backup. Copy file from /gmmp/stats.xml to computer and then just run gonemad2amarok
TODO:
- call script by gonemad2amarok point/to/stats.xml
- remove limitations?
- find other tags in the files (gonemad2amarok stats.xml /mnt/sdcard/) and find correct files more accurately
- print only changed ratings to screen, not all of them
- the other way around (amarok2gonemad -> copy ratings from computer to gonemad media player - for files copied to SD card)