Trying to browse my database using your library gives me 403 Forbidden errors. I'm guessing it has to do with iTunes
7 and a change in the DAAP protocol. I read something about one of the Python libraries not supporting iTunes 7 ...
Anyways; what I was trying to do:
$ irb -rubygems -rdigest/m4p -rnet/daap
>> daap = Net::DAAP::Client.new('localhost')
=> #<Net::DAAP::Client:0x1280278 @server_host="localhost", @request_id=nil, @validator=nil, @session_id=nil,
@password=nil, @server_port=3689, @connected=false, @log=#<Logger:0x1280214 @level=0, @formatter=nil,
@default_formatter=#<Logger::Formatter:0x12801ec @datetime_format=nil>, @progname=nil, @logdev=nil>>
>> daap.connect_db {|db| puts db.inspect}
Net::HTTPServerException: 403 "Forbidden"
from /opt/local/lib/ruby/1.8/net/http.rb:2065:in `error!'
from /opt/local/lib/ruby/gems/1.8/gems/daapclient-0.2.2/lib/net/daap.rb:146:in `do_get'
from /opt/local/lib/ruby/gems/1.8/gems/daapclient-0.2.2/lib/net/daap.rb:108:in `databases'
from /opt/local/lib/ruby/gems/1.8/gems/daapclient-0.2.2/lib/net/daap.rb:94:in `connect_db'
from (irb):2
You also had some bugs in your use of the @connected variable. I fixed some of those in a patch I submitted, but i didn't
see a bug in Client#connect_db ... If you get an exception (like above) the rest of connect_db will be skipped, and
the connection will not be closed. I saw this in iTunes (n users connected). If you add an ensure block to connect_db,
it works fine:
def connect_db(&block)
raise ArgumentError if block.nil?
connect
begin
databases.each { |db| block.call(db) }
ensure
disconnect
end
end
--
Rune Hammersland |