This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Import Ratings from iTunes XML Library

Tags: None
(comma "," separated)
Aaron Cooper
Registered Member
Posts
104
Karma
0
I\'ve been searching through the forum for a good half hour and I haven\'t found anything that solves my problem.

I\'ve been rating and playing my songs in iTunes for the last few months and have logged several thousand \"listens\" and rated ~7000 songs. I just recently switch to Kubuntu and amaroK, and was looking for a way to import the ratings and playcounts from my iTunes library XML file so I don\'t have to redo all that work.

Are there any tools available to do this or are there any SQL gurus out there who can write up a set of commands I can run on my amarok db to apply the ratings/playcounts found in my iTunes XML?

I would REALLY appreciate it if someone could help me out here! :)

Cheers,
-Aaron
Aaron Cooper
Registered Member
Posts
104
Karma
0
Any database gurus out there?
Aaron Cooper
Registered Member
Posts
104
Karma
0
I'm sure there's more than just me who wants this feature!  What better way to get iTunes users to switch over than by allowing them to import their iTunes information!?  Even Songbird at 0.1.1 had an import iTunes XML extension!  Where's amaroK's??? :confused:
Sogno
Karma
0
Ah, someone with the same idea!

I would also very much appreciate this functionality and I think many more people would, too. Re-rating every song is a hassle, especially with large collections and preserving the playcount is nice too. There also exists a plugin for Winamp which generates an XML for the library, so this possibility would be useful for Winamp users as well. Might even encourage more people to switch to amaroK/Linux.  :wink:

P.S.: AmaroK is truly the best player around today.  :cool:
Aaron Cooper
Registered Member
Posts
104
Karma
0
I got my roomate to write up a Python script to do this.  Currently, it imports ratings, playcounts, and he set the createdate/accessdate to today's date.  It requires some formatting of your iTunes XML file (removing the junk at the beginning and trimming the playlists at the end), but it did a great job once that was taken care of.

I'll post the script (rename to convert.pl) and an excerpt of my XML file now in case anyone wants to build off it.  I don't know if I'll get him to clean it up or improve on it, because we've already used it to update my library.  :)

Cheers!
User avatar
sebr
Moderator
Posts
301
Karma
0
fantastic! this is definitely something that should be extrapolated some more into a fully fledged script

You don't need to set the dates to today - you can read the file creation time directly, and then grab the last played date from the xml file!
Aaron Cooper
Registered Member
Posts
104
Karma
0
Seb Ruiz wrote:You don't need to set the dates to today - you can read the file creation time directly, and then grab the last played date from the xml file!


Ya, that was more for ease of use.  I didn't overly care about the dates, more so the ratings and playcounts.  Something else that could be added to the script (which I did thru sqlite3 afterwards) was set the Score to (rating*10).  That worked pretty nicely for me.
headlessbob
Registered Member
Posts
4
Karma
0
I decided to work out a "full" perl script to do this. Its a little messy, but it works (for me). It imports user ratings, play counts, date added, date last played, and even generates a score based on rating and play count.
... hope it helps somebody out there ;)

Enjoy (should be attached to this post...)

[Edit...] Seems that for a large swath of tracks the calculated score will be updated but not the play count, rating, or dates. the Sqlite output looks fine, it really makes no sense. It seems to happen with files in directories that don't have proper casing for the artists (iTunes db is pretty lazy when it comes to updating uppercase/lowercase between db artist name and the directory it creates). But i'd think that if the directory name is technically wrong, it shouldn't update any data to the sqlite db... yet it still updates the score. Any thoughts?[/Edit]

Last edited by headlessbob on Fri Aug 18, 2006 11:30 am, edited 1 time in total.
headlessbob
Registered Member
Posts
4
Karma
0
I figured out the problem described in my last post.. turns out it was due to itunes being lazy in keeping casing on the filesystem and its database and amarok being strict on casing. So I wrote a second script to fix the problem....
Anyway, both of these scripts and a description are posted here: http://www.jobeus.net/~brian/itunesimport.html (external link...)

Hope this stuff helps somebody else out there! Maybe somebody could write a better script too... (I'm a brewer, not a programmer!)
Cheers
muro
Registered Member
Posts
3
Karma
0
I know, I posted it at another place as well, but as this is the same thing, here it goes again:

I made an amarok-script (so you can install it in amarok and use it from there) for itunes ratings and last dale played, you can download it here:
http://www.slovenskoo.com/itunesratings .

I will try to add play count in the near time. The code is quite ugly, I did't do much ruby programming yet, but it should work. Any comments or bug reports are appreciated - see the page for contact info.
pineapples
Registered Member
Posts
2
Karma
0
Hello...I've been trying to use the perl script posted here, but the outcome is always ¨Successfully added 0 entries to the database of 0 entries in the XML file." Does anyone know what might be causing this?
pineapples
Registered Member
Posts
2
Karma
0
Hm...I solved that problem, but now whenever I try to run the script (or the second line in the fix stats urls script) I get this error:

SQL error: unsupported file format

Does anyone know how to fix this? It didn't happen when I was trying the script out, before I uncommented the line that actually changed the playcounts/stats in collection.db.
e235
Registered Member
Posts
15
Karma
0
If you are getting that message, it probably means your version of SQLite is not up-to-date enough to read Amarok's database. 3.3.8 is current. I was getting that with 3.2.8, but 3.3.6 read it fine.

Last edited by e235 on Mon Nov 20, 2006 5:28 am, edited 1 time in total.
LvanderRee
Registered Member
Posts
3
Karma
0
I've modified the plugin from Pavol Murin,

I've changed the way to match songs.
It now doesn't search per artist and song, but by looking at the location of the files. I also enabled it that non-rated but played played songs are added to the statistics and the device-id is correctly set (and unique-id, but I don't think this was very important).

I also fixed the last played and Added dates. The device ID needs to be set, I think it, to make the link with the song in your playlist.

One failure now is that It has some problems with accents on letters in the filenames. I tried to fix this by replacing letters with accents by a _ (which is any character in MySQL, I don't know if this holds for other DBMS). This can certainly be improved, by someone  ;-)

Also I didn't looked at or changed the way the ratings are being calculated. Maybe this needs some working too.

Finnally I only looked at empty statistic tables. So if you already have statistics, I don't know if it will update these (correctly), probably not...


I imported almost 6000 song ratings and playcounts and it gave errors for I think +/-30 songs, only because of the accents on letters in the filename/filepath.


You can download it from fun4me.demon.nl/~leon/iTunesRatingsLeon.amarokscript.tar.bz2

Last edited by LvanderRee on Wed Nov 29, 2006 6:22 pm, edited 1 time in total.
Creap
Registered Member
Posts
3
Karma
0
OS
Hm..

I just tried LvanderRee's script, but I couldn't get it to work. Does it matter if I have my database in SQLite or MySQL (I use the latter)?

I'm not sure if I used it the right way though, here's what I did:

1) Imported all my songs into Amarok, no file- or directory names changed since the iTunes Database Export
2) Started the script. A progress bar appeared in a "yellow bubble" at the lower left of the Amarok window, completed in about 5 seconds, and no dialog window or anything appeared where I could select my iTunes DB, so I tried:
3) Added my iTunes XML Database with "Add Media".
4) Tried running the script again.

Nothing happened.

This was all done with Amarok 1.4.3, Ubuntu Edgy Eft under Gnome.

Thanks.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]