Overview
PyPi module | N/A | |||||||||||||||||||||||||||||||||||
git repository | https://bitbucket.org/arrizza-public/fix-my-rbox | |||||||||||||||||||||||||||||||||||
git command | git clone git@bitbucket.org:arrizza-public/fix-my-rbox.git | |||||||||||||||||||||||||||||||||||
Verification Report | https://arrizza.com/web-ver/python-fix-my-rbox-report.html | |||||||||||||||||||||||||||||||||||
Version Info |
|
- installation: see https://arrizza.com/setup-common.html
Summary
I have about 2200 songs in RhythmBox on Ubuntu. To use the "My Top Rated" playlist, I rated all of them. That took quite a few days, and it was difficult to do.
Then my PC broke.
Luckily, I was able to copy all the music over to my new PC. Started up RhythmBox and I realized I'd have to rerate all of those songs!
Found out that there is a file ~/.local/share/rhythmbox/rhythmdb.xml
that holds
all the song info used by RhythmBox.
Copied this over from my old PC and compared to the new XML file.
The one on my new PC did not have the "rating" field.
I wrote a python script to copy the data over. Tried it in RhythmBox and it worked! I can now have only "My Top Rated" play 4 and 5-star songs.
Typical song entry
Here's a typical song entry in the XML file:
<entry type="song">
<title>Love, Life And Money</title>
<genre>Blues Rock</genre>
<artist>Johnny Winter</artist>
<album>3rd Degree</album>
<track-number>2</track-number>
<duration>320</duration>
<file-size>7907378</file-size>
<location>file:///home/myname/Music/Johnny%20Winter%20-%203rd%20Degree/02%20-%20Love,%20Life%20And%20Money.mp3</location>
<mtime>1396072852</mtime>
<first-seen>1702098030</first-seen>
<last-seen>1738475340</last-seen>
<rating>2</rating> <== the rating to copy over
<date>725007</date>
<media-type>audio/mpeg</media-type>
<composer>Unknown</composer>
</entry>
Run
NOTE: Backup your xml files BEFORE you run any of these!
- ensure RhythmBox is not running. It may interact with the db while this script is modifying it.
- run
./do_db_get_current
; do only once - copy the previous rhythmdb.xml file to this directory; name it "rhythmdb-prev.xml"
- at this point, these files should exist:
- rhythmdb-curr.xml: the current db file with no ratings in it
- rhythmdb-prev.xml: the previous db file with ratings in it
- run
./doit
- check rhythmdb-update.xml exists
- check the contents of rhythmdb-update.xml for expected ratings
- you can use
./doit --verbose
to see a bit more information about the XML content
- run
./do_db_update
- start RhythmBox and check ratings are as expected
Notes:
I copied over my music from the old PC to the same directory name in the new PC (~/Music). That made the search for the matching song very easy (since the file names were unique).
The song title is not unique. There are songs by two artists with the same name and there are the same song on two different albums by the same artist. That scenario would have been much more complicated to solve.