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 ?
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:
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.
Ryan Davis wrote:
···
On Jul 20, 2007, at 05:40 , cypher.dp@gmail.com wrote:
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: