Class: Net::DAAP::DAAPv3

Inherits:
Object
  • Object
show all
Defined in:
lib/net/daap.rb

Overview

This class is used for generating a Client-DAAP-Validation header for iTunes servers newer than 4.2, or something.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDAAPv3

Returns a new instance of DAAPv3.



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/net/daap.rb', line 254

def initialize
  @seeds = []
  (0..255).each do |i|
    string = String.new
    string += (i & 0x40) != 0 ? "eqwsdxcqwesdc"      : "op[;lm,piojkmn"
    string += (i & 0x20) != 0 ? "876trfvb 34rtgbvc"  :  "=-0ol.,m3ewrdfv"
    string += (i & 0x10) != 0 ? "87654323e4rgbv " : "1535753690868867974342659792"
    string += (i & 0x08) != 0 ? "Song Name"          : "DAAP-CLIENT-ID:"
    string += (i & 0x04) != 0 ? "111222333444555"    : "4089961010"
    string += (i & 0x02) != 0 ? "playlist-item-spec" : "revision-number"
    string += (i & 0x01) != 0 ? "session-id"         : "content-codes"
    string += (i & 0x80) != 0 ? "IUYHGFDCXWEDFGHN"   : "iuytgfdxwerfghjm" 
    @seeds << Digest::M4P.new(string).to_s.upcase
  end
end

Instance Attribute Details

#seedsObject (readonly)

Returns the value of attribute seeds.



253
254
255
# File 'lib/net/daap.rb', line 253

def seeds
  @seeds
end

Instance Method Details

#validate(path, select = 2, req_id = nil) ⇒ Object

Returns a validation header using a custom MD5 called Digest::M4P



270
271
272
273
274
275
276
277
# File 'lib/net/daap.rb', line 270

def validate(path, select = 2, req_id = nil)
  string = String.new
  string += path
  string += "Copyright 2003 Apple Computer, Inc."
  string += @seeds[select]
  string += req_id.to_s if req_id != nil
  Digest::M4P.new(string).to_s.upcase
end