iTunes and Rhythmbox Ratings

A couple months ago, I moved my trusty Alienware laptop from Windows XP to Ubuntu. So far, I'm very happy with using Linux. It's faster, more stable, runs Beryl (so I can get all my nifty visualizations), and most important of all, isn't a Microsoft product.

There are, of course, some things I miss. Photoshop is a big one; The Gimp just doesn't feel natural enough. I also sometimes miss the advanced features of the Microsoft Office suite, though usually OpenOffice does a fine job. But what I miss most of all are the song ratings I worked so hard to put into iTunes.

At first, I tried using Amarok for my music, but found it to be a little sluggish in GNOME, outside of its natural, K-flavored environment. After switching to Rhythmbox, I was much happier. Rhythmbox has similar features to iTunes, like smart playlists, podcasts and internet radio, but with a much smaller footprint. But because there was no easy way to transfer ratings from iTunes, my main method of sorting and categorizing songs, I often found myself skipping through 10 or more songs to find something I wanted to listen to.

I searched the web for ways to import iTunes ratings to Rhythmbox, but came across nothing useful. So, like any good hacker, I decided to write my own. Using Python and an example of how to parse the iTunes library, I figured out how to extract the ratings for each song. Next, I wrote a class to parse the Rhythmbox Library, using much of the same code as the iTunes parser. Finally, I found a tutorial on proper XML generation, which helped me write the output of the updated Rhythmbox Library.

The script can be found at http://code.google.com/p/itunes-to-rhythmbox-ratings/. Enjoy, and let me know if you find any bugs.

Posted May 21, 2007 - 29 Comments

At 12:26 AM on May 22, 2007, alex said,

why would you have songs in your itunes library you dont like? when are you moving back to nyc?

At 2:32 AM on May 22, 2007, Tyler said,

You know, things like podcasts or songs I only listen to occasionally. I should be back in NYC around mid-July, unless plans change.

At 1:41 PM on May 22, 2007, Poof! said,

Have you found a place yet?

At 11:18 PM on May 23, 2007, Tyler said,

No, not yet.

At 8:27 AM on June 22, 2007, frederic said,

Hello! I have recently switched from windows to the penguin and I am quite happy about that. However, I am now tackling the multimedia part of the switch, and I have some troubles importing ratings from my itunes library.

After some searches, I found you script. However, since I am quite new to those Python scripts, I can't make it work! After downloading the script, I tried a:

sudo python transferRatings-0.8. py ~/data/iTunes/iTunes Music Library.xml

which does not do anything apart telling me this:

Usage: transferRatings-0.8.py iTunesLibraryFile [RhythmboxLibraryFile]

transferRatings-0.8.py copies your iTunes ratings into your Rythmbox library...

Any ideas? Thx for your help!

At 6:24 PM on June 29, 2007, Tyler said,

I'm out of the country right now, but I'll take a look at it when I get back next week.

My best guess is that it isn't finding the Rhythmbox library file. My second best guess is that I left a bug in it. I'll post here again when I have a better answer for you. Sorry about the hassle.

At 4:32 AM on June 30, 2007, frederic said,

Hi!

Yes, I have seen that! Have a good trip! Btw, I also guess it's because it can't find the Rhytmbox library file or maybe I misspecified the iTunes one, but I don't think so.

Thanks a lot for your help, and you don't have to be sorry: I am glad that someone did think about doing something like that!

frederic

At 12:34 AM on July 16, 2007, Tyler said,

Sorry for the delay responding. What happens when you specify the Rhythmbox library location?

At 12:54 AM on July 16, 2007, Tyler said,

I've fixed one bug. When a Rhythmbox library was not specified, Python could not use '~/' for the home directory.

This wouldn't have produced the results you got, Frederic, but it might be worth trying again. Check the project page (above) for the download and better instructions.

At 7:21 AM on August 23, 2007, Bartong said,

Hi Tyler, great to see someone working on a tool like this, I'm sure it'll soon be in high demand.

I just have a problem, when i run the command as specified I get the following output:

Usage: transferRatings-0.8.1.py iTunesLibraryFile [RhythmboxLibraryFile]

transferRatings-0.8.1.py copies your iTunes ratings into your Rythmbox library. To ensure nothing is lost, a backup of your Rhythmbox Library will be made. It is recommended that you quit Rhythmbox before running this script.

Arguments: iTunesLibraryFile - This file is usually: {Music Folder}/iTunes/iTunes Music Library.xml

RhythmboxLibraryFile [optional] - Usually found at: /home/username/.gnome2/rhythmbox/rhythmdb.xml If this argument is not specified, the default location will be used instead.

And thats it!

Any ideas what I'm doing wrong or if I'm missing something needed to make this script work?

At 5:08 PM on August 27, 2007, Tyler said,

For those of you having problems with the script, remember that you have to escape spaces with backslashes in Linux, so instead of

python transferRatings-0.8.1.py /path/to/iTunes Music Library.xml

you should do

python transferRatings-0.8.1.py /path/to/iTunes\ Music\ Library.xml
At 12:46 PM on September 11, 2007, Simon said,

I also tried to import my ratings from the iTunes library to rhythmbox, and it didn't work at first, either.

So, having tried it as normal user, I then did two things to make it work:

First, I switched to su root and... second: I rated every song in rhythmbox with some rating (f.e. 3 stars or something). Only when a song is rated, rhythmbox.xml contains a section for that song.

After that I tried everything again (as su) and it worked fine.

Not sure whether switching to root was the answer or creating a section for each and every song in the library by making a "dump-rating".

Perhaps this comment helps anybody else, for it is a very useful and well done script.

Thank you!

At 5:38 PM on September 12, 2007, Tyler said,

Thanks for the heads-up Simon, hopefully that'll help anyone who is still having problems.

At 9:49 PM on November 3, 2007, Chad said,

Hello,

I just wanted to say a big thank you for the script! I successfully transfered my iTunes library tonight!

One minor issue I encountered was that after I imported my music into rhythmbox, my rhythmbox XML file did not have any "rating" tags associated with each song. These are required by the script.

To workaround, I opened rhythmbox and assigned all my songs a rating of '1', then I ran the script, restarted rhythmbox, and finally changed all '1' ratings to unrated. (I didn't have any '1' ratings in my iTunes library so I didn't lose any ratings by this method)

thanks again!

At 11:17 AM on November 5, 2007, Tyler said,

Thanks Chad, I'll take a look at it and get it fixed as soon as I get a spare moment.

At 11:20 AM on November 20, 2007, Nick said,

I had the same issue when I moved to Ubuntu and wrote my own version of this in Perl. Code can be found at:

http://www.mythgaming.net/transferratingsperl.zip

At 11:30 PM on November 29, 2007, Bowen said,

I just switched from Windows to Ubuntu and had the same thought about moving my song ratings from iTunes to Rhythmbox. Glad to find this page - as usual, someone's been there before!

Since I know perl better than python, I took the perl script that Nick wrote and added to it a bit so that Play Count and Play Date (date last played) are moved across as well, since these are very useful for smart playlists...

Here is the updated perl script: http://dwelle.org/eg/transferratingsperl.zip

Thanks Tyler and Nick!

At 12:41 PM on December 2, 2007, dekaru said,

hey Tyler !

Thanks a lot for this script.. really useful!

Same story as Chad, though.. now it all works OK and I have my library fixed :)

I do think that should be on the project's webpage !

Cheers

At 12:44 PM on December 2, 2007, dekaru said,

btw... is there any way of making Rhythmbox look leaner ? (more like iTunes) ? It's cool but it sure does waste a lot of space...

thx again.. i'll check back on updates before recommending, if you mind ! :)

At 9:22 AM on December 3, 2007, Adam said,

Thanks for the code, I am going to use it to write my own python script to delete mp3's with only 1 star from my library.

Also just to say I also moved to linux a few months ago after (too) many years on Windows and share your feeling about Gimp (no layer effects, layer groups) But I have found that I can run photoshop CS2 quite quickly and stable under wine. I also run Macromedia Flash 8 like this.

Hope that helps.

At 4:31 PM on December 26, 2007, Brett said,

I'm trying to get this included in Ubuntu's migration-assistant: https://launchpad.net/ubuntu/+source/migration-assistant/

Maybe you can help?

Here's my bug: https://bugs.launchpad.net/ubuntu/+source/migration-assistant/+bug/176573

At 1:28 PM on April 16, 2008, mp said,

Hi Tyler. When I try to use the script, it says "Backing up Rhythmbox Library Could not back up Rhythmbox Library from [~/.gnome2/rhythmbox/rhythmdb.xml] to [~/.gnome2/rhythmbox/rhythmdb.xml].bak." What's wrong?

At 5:50 PM on April 16, 2008, Tyler said,

Hmm, sounds like a permission error. Check that the file is there and that you have permission to read it and write to the directory.

Unfortunately, I've removed my Ubuntu installation because I needed to use Photoshop, and it's just to slow and ugly with Wine, so this project is on a bit of a hiatus until I decide to go back to Linux.

At 2:10 AM on May 11, 2008, Wes said,

This script, for me at least, doesn't distinguish between the two versions of the same song (different albums, live & studio, etc)

Is it supposed to? If not, how would that be included?

Thanks!

At 4:58 AM on May 17, 2008, Ben said,

I'm getting slowly more disappointed as time goes one. Rhythmbox doesn't handle podcasting very well at all, often a 30 minute podcast downloads only a few seconds, and there's no option to refresh, so I have to delete the remnant and try to get it direct through a browser. Next comes Opera and Thunderbird and Firefox, which work well when they are in the mood. Using opera now, I just had to dump my session and start fresh because it didn't like something and crashed within 15 seconds of opening...

Praise is due for trying, but it's still rather less polished than the rather outdated XP 2003 in many ways...

At 10:15 PM on June 14, 2008, Zach Denton said,

Wow! This is absolutely fantastic. Thanks - it worked perfectly after I ran it as root and applied a rating to all items in my Rhythmbox library.

At 5:15 PM on June 16, 2008, Memoman said,

I got an error that said:

[code]Could not parse iTunes file /media/h/Documents and Settings/blah blah[/code]

So what I did to fix it was to copy the Itunes Music Library.xml file to my Ubuntu Desktop and that's it. (I also rated every song one star before, just following the advice I read here.

At 8:35 AM on June 29, 2008, chill said,

I want to do exactly the oposite, moving ratings from rhythmbox to itunes. Can i do it with your script, or it needs heavy modification?

At 11:16 PM on June 29, 2008, chill said,

also, there is a commented version of the script? i only found plain code.

Name:
Email:

Website:

Comment:

The color of the sky is: