Class: Net::DAAP::DAAPv3
- Inherits:
-
Object
- Object
- Net::DAAP::DAAPv3
- 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
-
#seeds ⇒ Object
readonly
Returns the value of attribute seeds.
Instance Method Summary collapse
-
#initialize ⇒ DAAPv3
constructor
A new instance of DAAPv3.
-
#validate(path, select = 2, req_id = nil) ⇒ Object
Returns a validation header using a custom MD5 called Digest::M4P.
Constructor Details
#initialize ⇒ DAAPv3
Returns a new instance of DAAPv3.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/net/daap.rb', line 212 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
#seeds ⇒ Object (readonly)
Returns the value of attribute seeds.
211 212 213 |
# File 'lib/net/daap.rb', line 211 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
228 229 230 231 232 233 234 235 |
# File 'lib/net/daap.rb', line 228 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 |