[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

parsing iTunes Libary

cypher.dp

7/20/2007 12:40:00 PM

Hello everybody !

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

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

5 Answers

Ryan Davis

7/20/2007 8:57:00 PM

0


On Jul 20, 2007, at 05:40 , cypher.dp@gmail.com wrote:

> I thought about writing something like that:
> http://code.google.com/p/itunes-to-rhythmbo...
>
> 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 ?

I just use regular expressions:

http://blog.zenspider.com/archive...
that_stupid_thing_i_wrote_the_other_day_part_2.html



cypher.dp

7/20/2007 9:52:00 PM

0

Thanks a lot Ryan !

You safed me from some nasty work.

Dominik


2007/7/20, Ryan Davis <ryand-ruby@zenspider.com>:
>
> On Jul 20, 2007, at 05:40 , cypher.dp@gmail.com wrote:
>
> > I thought about writing something like that:
> > http://code.google.com/p/itunes-to-rhythmbo...
> >
> > 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 ?
>
> I just use regular expressions:
>
> http://blog.zenspider.com/archive...
> that_stupid_thing_i_wrote_the_other_day_part_2.html
>
>
>
>

msnews.microsoft.com

7/21/2007 1:43:00 AM

0

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:
>
>> I thought about writing something like that:
>> http://code.google.com/p/itunes-to-rhythmbo...
>>
>> 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 ?
>
> I just use regular expressions:
>
> http://blog.zenspider.com/archives/2007/03/that_stupid_thing_i_wrote_the_other_day_p...
>
>
>
>
>

hengist podd

7/21/2007 8:33:00 AM

0

Dominik wrote:
> I thought about writing something like that:
> http://code.google.com/p/itunes-to-rhythmbo...
>
> I wanted to parse the library with REXML but the file is quite big.

You could look into using libxml:

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


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.rubyfor... 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/...


HTH

has
--
http://appscript.sourc...
http://rb-appscript.rub...

--
Posted via http://www.ruby-....

cypher.dp

7/21/2007 11:06:00 AM

0

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, hengist podd <has.temp3@virgin.net>:
> Dominik wrote:
> > I thought about writing something like that:
> > http://code.google.com/p/itunes-to-rhythmbo...
> >
> > I wanted to parse the library with REXML but the file is quite big.
>
> You could look into using libxml:
>
> http://libxml.ruby...
> http://raa.ruby-lang.org/search.rhtml?sea...
>
>
> 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.rubyfor... 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/...
>
>
> HTH
>
> has
> --
> http://appscript.sourc...
> http://rb-appscript.rub...
>
> --
> Posted via http://www.ruby-....
>
>