parsing iTunes Libary

C

cypher.dp

Hello everybody !

I thought about writing something like that:
http://code.google.com/p/itunes-to-rhythmbox-ratings/

I wanted to parse the library with REXML but the file is quite big.

Is there a possibility to parse only a part of the file ?
Or parses only a certain depth of the tree ?
Does anybody know an existing tool for the iTunes library ?

Thanks

Dominik
 
M

Mike Cargal

I also recently needed to parse the AlbumData.xml. Started into it with
REXML and realized that it was becoming something of a pain do to the
rather inane XML that Apple uses. So I searched around and found the
plist gem. It parses it (and other files that use the same strucure_
and gives you hashmaps that you can navigate rather easily.

It is probably slower than the regex code here and it loads everything
into memory. But I found it pretty helpful.
 
H

hengist podd

Dominik said:
I thought about writing something like that:
http://code.google.com/p/itunes-to-rhythmbox-ratings/

I wanted to parse the library with REXML but the file is quite big.

You could look into using libxml:

http://libxml.rubyforge.org/
http://raa.ruby-lang.org/search.rhtml?search=libxml


Another option would be to access iTunes via its COM (Windows) or Apple
event (OS X) API. e.g. Using rb-appscript
<http://rb-appscript.rubyforge.org> on OS X:

#!/usr/bin/env ruby

require 'appscript'
include Appscript

t = app('iTunes').library_playlists[1].tracks

t.name.get.zip(t.artist.get, t.rating.get).each do |name, artist,
rating|
p name, artist, rating
end


There's also a project to provide a common cross-platform API, although
I don't know how far on it is yet:

http://rubyforge.org/projects/rb-itunes/


HTH

has
 
C

cypher.dp

Thanks a lot everybody !

I tried plist but it didn't work. Don't ask me why.
Know I'm using regexp similar to Ryan.
Maybe I'll also have another look at libxml and so on.

Dominik



2007/7/21 said:
Dominik said:
I thought about writing something like that:
http://code.google.com/p/itunes-to-rhythmbox-ratings/

I wanted to parse the library with REXML but the file is quite big.

You could look into using libxml:

http://libxml.rubyforge.org/
http://raa.ruby-lang.org/search.rhtml?search=libxml


Another option would be to access iTunes via its COM (Windows) or Apple
event (OS X) API. e.g. Using rb-appscript
<http://rb-appscript.rubyforge.org> on OS X:

#!/usr/bin/env ruby

require 'appscript'
include Appscript

t = app('iTunes').library_playlists[1].tracks

t.name.get.zip(t.artist.get, t.rating.get).each do |name, artist,
rating|
p name, artist, rating
end


There's also a project to provide a common cross-platform API, although
I don't know how far on it is yet:

http://rubyforge.org/projects/rb-itunes/


HTH

has
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top