daapclient 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +36 -0
- data/EXAMPLES +79 -0
- data/LICENSE +340 -0
- data/NOTES +33 -0
- data/README +7 -31
- data/lib/net/daap.rb +34 -20
- data/lib/net/daap/album.rb +16 -0
- data/lib/net/daap/artist.rb +16 -0
- data/lib/net/daap/daap_version.rb +7 -0
- data/lib/net/daap/database.rb +54 -27
- data/lib/net/daap/dmap.rb +13 -24
- data/lib/net/daap/playlist.rb +4 -5
- data/lib/net/daap/song.rb +10 -8
- data/test/data/mt-daapd/02dd88de4b3a69c74bcc56c1acca9ae5.txt +0 -0
- data/test/data/mt-daapd/0de583b288d8ae30f89acb26d4c8535b.txt +0 -0
- data/test/data/mt-daapd/4146ec82a0f0a638db9293a0c2039e6b.txt +0 -0
- data/test/data/mt-daapd/51a2a6f2a53743bec7e79fe0d074dd28.txt +0 -0
- data/test/data/mt-daapd/6069971903eef3c8c71ec2c7b395bfeb.txt +0 -0
- data/test/data/mt-daapd/{e9a8e709c2116651157182f130207048.txt → 7102a16e834342b8264f1fb5226690e5.txt} +0 -0
- data/test/data/mt-daapd/9d29fb31969da7757fa2f4baa3a52fe9.txt +0 -0
- data/test/data/mt-daapd/a52dd33cc99471cc156528c06b22e709.txt +0 -0
- data/test/data/mt-daapd/a600829e59b3d719b32f25323a2719b0.txt +0 -0
- data/test/data/mt-daapd/e2552df8d742fe31d6cc6e1e41e496b3.txt +0 -0
- data/test/data/mt-daapd/fc631aa54b83344df9ccf1fbaa7684b0.txt +0 -0
- data/test/data/song_data.txt +0 -0
- data/test/data/song_structure.txt +209 -0
- data/test/mock_server.rb +56 -0
- data/test/server_saver.rb +31 -0
- data/test/tc_artists.rb +33 -0
- data/test/tc_client.rb +47 -116
- data/test/tc_download.rb +29 -0
- data/test/tc_playlist.rb +37 -0
- data/test/tc_protocol.rb +3 -0
- data/test/test_daap.rb +23 -0
- data/test/ts_daap.rb +7 -0
- metadata +41 -97
- data/doc/classes/Net.html +0 -127
- data/doc/classes/Net/DAAP.html +0 -168
- data/doc/classes/Net/DAAP/Client.html +0 -269
- data/doc/classes/Net/DAAP/Client.src/M000003.html +0 -20
- data/doc/classes/Net/DAAP/Client.src/M000004.html +0 -28
- data/doc/classes/Net/DAAP/Client.src/M000005.html +0 -33
- data/doc/classes/Net/DAAP/Client.src/M000006.html +0 -37
- data/doc/classes/Net/DAAP/Client.src/M000007.html +0 -20
- data/doc/classes/Net/DAAP/Client.src/M000008.html +0 -24
- data/doc/classes/Net/DAAP/Client.src/M000009.html +0 -18
- data/doc/classes/Net/DAAP/DAAPv2.html +0 -165
- data/doc/classes/Net/DAAP/DAAPv2.src/M000016.html +0 -30
- data/doc/classes/Net/DAAP/DAAPv2.src/M000017.html +0 -21
- data/doc/classes/Net/DAAP/DAAPv3.html +0 -178
- data/doc/classes/Net/DAAP/DAAPv3.src/M000018.html +0 -30
- data/doc/classes/Net/DAAP/DAAPv3.src/M000019.html +0 -23
- data/doc/classes/Net/DAAP/DMAP.html +0 -176
- data/doc/classes/Net/DAAP/DMAP.src/M000013.html +0 -20
- data/doc/classes/Net/DAAP/DMAP.src/M000014.html +0 -18
- data/doc/classes/Net/DAAP/DMAP.src/M000015.html +0 -24
- data/doc/classes/Net/DAAP/Database.html +0 -224
- data/doc/classes/Net/DAAP/Database.src/M000010.html +0 -25
- data/doc/classes/Net/DAAP/Database.src/M000011.html +0 -21
- data/doc/classes/Net/DAAP/Database.src/M000012.html +0 -35
- data/doc/classes/Net/DAAP/Playlist.html +0 -192
- data/doc/classes/Net/DAAP/Playlist.src/M000001.html +0 -24
- data/doc/classes/Net/DAAP/Playlist.src/M000002.html +0 -30
- data/doc/classes/Net/DAAP/Song.html +0 -208
- data/doc/classes/Net/DAAP/Song.src/M000020.html +0 -27
- data/doc/classes/Net/DAAP/Song.src/M000021.html +0 -19
- data/doc/created.rid +0 -1
- data/doc/files/CHANGELOG.html +0 -134
- data/doc/files/LICENSE.html +0 -531
- data/doc/files/README.html +0 -182
- data/doc/files/lib/net/daap/database_rb.html +0 -101
- data/doc/files/lib/net/daap/dmap_rb.html +0 -101
- data/doc/files/lib/net/daap/playlist_rb.html +0 -101
- data/doc/files/lib/net/daap/song_rb.html +0 -101
- data/doc/files/lib/net/daap_rb.html +0 -114
- data/doc/fr_class_index.html +0 -35
- data/doc/fr_file_index.html +0 -34
- data/doc/fr_method_index.html +0 -47
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
- data/lib/CVS/Entries +0 -1
- data/lib/CVS/Repository +0 -1
- data/lib/CVS/Root +0 -1
- data/lib/net/CVS/Entries +0 -2
- data/lib/net/CVS/Repository +0 -1
- data/lib/net/CVS/Root +0 -1
- data/lib/net/daap/CVS/Entries +0 -5
- data/lib/net/daap/CVS/Repository +0 -1
- data/lib/net/daap/CVS/Root +0 -1
- data/test/CVS/Entries +0 -4
- data/test/CVS/Repository +0 -1
- data/test/CVS/Root +0 -1
- data/test/data/CVS/Entries +0 -1
- data/test/data/CVS/Repository +0 -1
- data/test/data/CVS/Root +0 -1
- data/test/data/mt-daapd/079aca35773150da9fd98db10c7fd0c0.txt +0 -0
- data/test/data/mt-daapd/2972f65088b42a06b5d3ca089d71791d.txt +0 -0
- data/test/data/mt-daapd/440c2217e6207c54c317c296f71f9769.txt +0 -0
- data/test/data/mt-daapd/4d1ce9f941cbd823ed06f1f1baa5a3b9.txt +0 -0
- data/test/data/mt-daapd/7bded8b540fd082f102d25e181b47bc4.txt +0 -0
- data/test/data/mt-daapd/CVS/Entries +0 -11
- data/test/data/mt-daapd/CVS/Repository +0 -1
- data/test/data/mt-daapd/CVS/Root +0 -1
- data/test/data/mt-daapd/b3e894b87111bdba88e4765967f4b45a.txt +0 -0
- data/test/data/mt-daapd/d56b699830e77ba53855679cb1d252da.txt +0 -0
- data/test/data/mt-daapd/e61ce3062cb76770658896b778ad06cd.txt +0 -0
- data/test/data/mt-daapd/f9073959a0afacebfab7e3bf19c2714a.txt +0 -0
data/lib/net/daap/playlist.rb
CHANGED
@@ -6,11 +6,10 @@ module Net
|
|
6
6
|
attr_reader :itemcount, :persistentid, :name, :id
|
7
7
|
|
8
8
|
def initialize(args)
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@id = info['dmap.itemid']
|
9
|
+
@itemcount = args['dmap.itemcount']
|
10
|
+
@persistentid = args['dmap.persistentid']
|
11
|
+
@name = args['dmap.itemname']
|
12
|
+
@id = args['dmap.itemid']
|
14
13
|
@daap = args[:daap]
|
15
14
|
@db = args[:db]
|
16
15
|
end
|
data/lib/net/daap/song.rb
CHANGED
@@ -4,15 +4,17 @@ module Net
|
|
4
4
|
class Song
|
5
5
|
attr_reader :size, :album, :name, :artist, :format, :persistentid, :id
|
6
6
|
|
7
|
+
alias :to_s :name
|
8
|
+
|
7
9
|
def initialize(args)
|
8
|
-
|
9
|
-
@
|
10
|
-
@
|
11
|
-
|
12
|
-
@artist =
|
13
|
-
@format =
|
14
|
-
@persistentid =
|
15
|
-
@id =
|
10
|
+
@size = args['daap.songsize']
|
11
|
+
@album = args[:album]
|
12
|
+
@name = args['dmap.itemname']
|
13
|
+
#@artist = args['daap.songartist']
|
14
|
+
@artist = args[:artist]
|
15
|
+
@format = args['daap.songformat']
|
16
|
+
@persistentid = args['dmap.persistentid']
|
17
|
+
@id = args['dmap.itemid']
|
16
18
|
@daap = args[:daap]
|
17
19
|
@db = args[:db]
|
18
20
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
File without changes
|
Binary file
|
Binary file
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,209 @@
|
|
1
|
+
---
|
2
|
+
27328526:
|
3
|
+
:album: Warnings / Promises
|
4
|
+
:size: 5916800
|
5
|
+
:artist: Idlewild
|
6
|
+
:persistentid: 27328526
|
7
|
+
:format: mp3
|
8
|
+
:name: I Want A Warning
|
9
|
+
:itemid: 27328526
|
10
|
+
27328537:
|
11
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
12
|
+
:size: 5741662
|
13
|
+
:artist: The Unicorns
|
14
|
+
:persistentid: 27328537
|
15
|
+
:format: mp3
|
16
|
+
:name: Tuff Luff
|
17
|
+
:itemid: 27328537
|
18
|
+
27328521:
|
19
|
+
:album: Warnings / Promises
|
20
|
+
:size: 5617792
|
21
|
+
:artist: Idlewild
|
22
|
+
:persistentid: 27328521
|
23
|
+
:format: mp3
|
24
|
+
:name: "As If I Hadn't Slept"
|
25
|
+
:itemid: 27328521
|
26
|
+
27328543:
|
27
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
28
|
+
:size: 4681321
|
29
|
+
:artist: The Unicorns
|
30
|
+
:persistentid: 27328543
|
31
|
+
:format: mp3
|
32
|
+
:name: Ghost Mountain
|
33
|
+
:itemid: 27328543
|
34
|
+
27328538:
|
35
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
36
|
+
:size: 5805288
|
37
|
+
:artist: The Unicorns
|
38
|
+
:persistentid: 27328538
|
39
|
+
:format: mp3
|
40
|
+
:name: Sea Ghost
|
41
|
+
:itemid: 27328538
|
42
|
+
27328527:
|
43
|
+
:album: Warnings / Promises
|
44
|
+
:size: 4224
|
45
|
+
:artist: Idlewild
|
46
|
+
:persistentid: 27328527
|
47
|
+
:format: mp3
|
48
|
+
:name: Hidden Track 2
|
49
|
+
:itemid: 27328527
|
50
|
+
27328544:
|
51
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
52
|
+
:size: 2535811
|
53
|
+
:artist: The Unicorns
|
54
|
+
:persistentid: 27328544
|
55
|
+
:format: mp3
|
56
|
+
:name: The Clap
|
57
|
+
:itemid: 27328544
|
58
|
+
27328522:
|
59
|
+
:album: Warnings / Promises
|
60
|
+
:size: 6875264
|
61
|
+
:artist: Idlewild
|
62
|
+
:persistentid: 27328522
|
63
|
+
:format: mp3
|
64
|
+
:name: The Space Between All Things
|
65
|
+
:itemid: 27328522
|
66
|
+
27328528:
|
67
|
+
:album: Warnings / Promises
|
68
|
+
:size: 5306496
|
69
|
+
:artist: Idlewild
|
70
|
+
:persistentid: 27328528
|
71
|
+
:format: mp3
|
72
|
+
:name: Too Long Awake
|
73
|
+
:itemid: 27328528
|
74
|
+
27328523:
|
75
|
+
:album: Warnings / Promises
|
76
|
+
:size: 4825216
|
77
|
+
:artist: Idlewild
|
78
|
+
:persistentid: 27328523
|
79
|
+
:format: mp3
|
80
|
+
:name: Welcome Home
|
81
|
+
:itemid: 27328523
|
82
|
+
27328534:
|
83
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
84
|
+
:size: 2774011
|
85
|
+
:artist: The Unicorns
|
86
|
+
:persistentid: 27328534
|
87
|
+
:format: mp3
|
88
|
+
:name: Ready to Die
|
89
|
+
:itemid: 27328534
|
90
|
+
27328545:
|
91
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
92
|
+
:size: 7631889
|
93
|
+
:artist: The Unicorns
|
94
|
+
:persistentid: 27328545
|
95
|
+
:format: mp3
|
96
|
+
:name: Child Star
|
97
|
+
:itemid: 27328545
|
98
|
+
27328540:
|
99
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
100
|
+
:size: 4764396
|
101
|
+
:artist: The Unicorns
|
102
|
+
:persistentid: 27328540
|
103
|
+
:format: mp3
|
104
|
+
:name: Tuff Ghost
|
105
|
+
:itemid: 27328540
|
106
|
+
27328529:
|
107
|
+
:album: Warnings / Promises
|
108
|
+
:size: 4864128
|
109
|
+
:artist: Idlewild
|
110
|
+
:persistentid: 27328529
|
111
|
+
:format: mp3
|
112
|
+
:name: Love Steals Us From Loneliness
|
113
|
+
:itemid: 27328529
|
114
|
+
27328546:
|
115
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
116
|
+
:size: 7356555
|
117
|
+
:artist: The Unicorns
|
118
|
+
:persistentid: 27328546
|
119
|
+
:format: mp3
|
120
|
+
:name: Inoculate the Innocuous
|
121
|
+
:itemid: 27328546
|
122
|
+
27328524:
|
123
|
+
:album: Warnings / Promises
|
124
|
+
:size: 5765248
|
125
|
+
:artist: Idlewild
|
126
|
+
:persistentid: 27328524
|
127
|
+
:format: mp3
|
128
|
+
:name: Not Just Sometimes But Always
|
129
|
+
:itemid: 27328524
|
130
|
+
27328535:
|
131
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
132
|
+
:size: 2975312
|
133
|
+
:artist: The Unicorns
|
134
|
+
:persistentid: 27328535
|
135
|
+
:format: mp3
|
136
|
+
:name: "Let's Get Known"
|
137
|
+
:itemid: 27328535
|
138
|
+
27328530:
|
139
|
+
:album: Warnings / Promises
|
140
|
+
:size: 5744768
|
141
|
+
:artist: Idlewild
|
142
|
+
:persistentid: 27328530
|
143
|
+
:format: mp3
|
144
|
+
:name: Disconnected
|
145
|
+
:itemid: 27328530
|
146
|
+
27328541:
|
147
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
148
|
+
:size: 4032487
|
149
|
+
:artist: The Unicorns
|
150
|
+
:persistentid: 27328541
|
151
|
+
:format: mp3
|
152
|
+
:name: Jellybones
|
153
|
+
:itemid: 27328541
|
154
|
+
27328519:
|
155
|
+
:album: Warnings / Promises
|
156
|
+
:size: 5253248
|
157
|
+
:artist: Idlewild
|
158
|
+
:persistentid: 27328519
|
159
|
+
:format: mp3
|
160
|
+
:name: I Understand It
|
161
|
+
:itemid: 27328519
|
162
|
+
27328547:
|
163
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
164
|
+
:size: 4855761
|
165
|
+
:artist: The Unicorns
|
166
|
+
:persistentid: 27328547
|
167
|
+
:format: mp3
|
168
|
+
:name: I Was Born (A Unicorn)
|
169
|
+
:itemid: 27328547
|
170
|
+
27328525:
|
171
|
+
:album: Warnings / Promises
|
172
|
+
:size: 5597312
|
173
|
+
:artist: Idlewild
|
174
|
+
:persistentid: 27328525
|
175
|
+
:format: mp3
|
176
|
+
:name: Blame It On Obvious Ways
|
177
|
+
:itemid: 27328525
|
178
|
+
27328536:
|
179
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
180
|
+
:size: 5871881
|
181
|
+
:artist: The Unicorns
|
182
|
+
:persistentid: 27328536
|
183
|
+
:format: mp3
|
184
|
+
:name: Les OS
|
185
|
+
:itemid: 27328536
|
186
|
+
27328542:
|
187
|
+
:album: "Who Will Cut Our Hair When We're Gone?"
|
188
|
+
:size: 3216155
|
189
|
+
:artist: The Unicorns
|
190
|
+
:persistentid: 27328542
|
191
|
+
:format: mp3
|
192
|
+
:name: "I Don't Wanna Die"
|
193
|
+
:itemid: 27328542
|
194
|
+
27328520:
|
195
|
+
:album: Warnings / Promises
|
196
|
+
:size: 5849216
|
197
|
+
:artist: Idlewild
|
198
|
+
:persistentid: 27328520
|
199
|
+
:format: mp3
|
200
|
+
:name: El Capitan
|
201
|
+
:itemid: 27328520
|
202
|
+
27328531:
|
203
|
+
:album: Warnings / Promises
|
204
|
+
:size: 8157312
|
205
|
+
:artist: Idlewild
|
206
|
+
:persistentid: 27328531
|
207
|
+
:format: mp3
|
208
|
+
:name: Goodnight
|
209
|
+
:itemid: 27328531
|
data/test/mock_server.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
file_dir = nil
|
5
|
+
if FileTest.exists?('test/data')
|
6
|
+
file_dir = 'test/data'
|
7
|
+
else
|
8
|
+
file_dir = 'data'
|
9
|
+
end
|
10
|
+
FILE_DIR = file_dir
|
11
|
+
|
12
|
+
File.open("#{FILE_DIR}/song_structure.txt", 'r') {|f| HASH = YAML.load(f.read) }
|
13
|
+
File.open("#{FILE_DIR}/song_data.txt", 'r') { |f| FILE_DATA = f.read }
|
14
|
+
SERVER = 'localhost'
|
15
|
+
|
16
|
+
module Net
|
17
|
+
class Container
|
18
|
+
attr_reader :header, :body
|
19
|
+
|
20
|
+
def initialize(args)
|
21
|
+
@header = args[:header]
|
22
|
+
@body = args[:body]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class HTTP
|
27
|
+
def self.new
|
28
|
+
allocate
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.start(*args)
|
35
|
+
Net::HTTP.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def get(*args, &block)
|
39
|
+
md5 = Digest::MD5.new(args[0])
|
40
|
+
contents = nil
|
41
|
+
dir = nil
|
42
|
+
if FileTest.exists?('test/data')
|
43
|
+
dir = 'test/data/mt-daapd/'
|
44
|
+
else
|
45
|
+
dir = 'data/mt-daapd/'
|
46
|
+
end
|
47
|
+
File::open(dir + md5.to_s + ".txt" , "r") do |file|
|
48
|
+
contents = file.read
|
49
|
+
end
|
50
|
+
Container.new(:body => contents, :header => {
|
51
|
+
'content-type' => 'dmap',
|
52
|
+
'daap-server' => 'mock'
|
53
|
+
})
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Net
|
2
|
+
module DAAP
|
3
|
+
class Client
|
4
|
+
def do_get(request, &block)
|
5
|
+
@log.debug("do_get called")
|
6
|
+
url = String.new('/' + request)
|
7
|
+
if @session_id
|
8
|
+
url += url =~ /\?/ ? "&" : "?"
|
9
|
+
url += "session-id=20"
|
10
|
+
end
|
11
|
+
|
12
|
+
@log.debug("Fetching url: #{url}")
|
13
|
+
|
14
|
+
res = nil
|
15
|
+
md5 = Digest::MD5.new(url)
|
16
|
+
File.open(md5.to_s + ".txt", "w") do |file|
|
17
|
+
res = @http_client.get(url, request_headers(url), nil, &block)
|
18
|
+
file.write res.body
|
19
|
+
end
|
20
|
+
@log.debug("Done Fetching url: #{url}")
|
21
|
+
|
22
|
+
content_type = res.header['content-type']
|
23
|
+
if request !~ /(?:\/items\/\d+\.|logout)/ && content_type !~ /dmap/
|
24
|
+
raise "Broken response"
|
25
|
+
end
|
26
|
+
|
27
|
+
res.body
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/test/tc_artists.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'net/daap'
|
6
|
+
require 'mock_server'
|
7
|
+
|
8
|
+
class DAAPCLientArtistTest < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@daap = Net::DAAP::Client.new(SERVER)
|
11
|
+
@daap.connect
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
@daap.disconnect
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_artists
|
19
|
+
db = @daap.databases.first
|
20
|
+
|
21
|
+
album_songs = 0
|
22
|
+
db.albums.each { |a|
|
23
|
+
album_songs += a.songs.length
|
24
|
+
}
|
25
|
+
assert_equal(db.songs.length, album_songs)
|
26
|
+
|
27
|
+
artist_songs = 0
|
28
|
+
db.artists.each { |a|
|
29
|
+
artist_songs += a.songs.length
|
30
|
+
}
|
31
|
+
assert_equal(db.songs.length, artist_songs)
|
32
|
+
end
|
33
|
+
end
|
data/test/tc_client.rb
CHANGED
@@ -1,119 +1,65 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "test")
|
3
|
+
|
1
4
|
require 'test/unit'
|
2
5
|
require 'net/daap'
|
3
|
-
require '
|
6
|
+
require 'mock_server'
|
4
7
|
|
5
|
-
class
|
6
|
-
def
|
7
|
-
@
|
8
|
-
|
9
|
-
@connected = 1
|
10
|
-
@dsn
|
8
|
+
class DAAPClient_Test < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@daap = Net::DAAP::Client.new(SERVER)
|
11
|
+
@daap.connect
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def teardown
|
15
|
+
@daap.disconnect
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
contents = file.read
|
21
|
-
end
|
22
|
-
contents
|
18
|
+
def test_connect
|
19
|
+
daap = Net::DAAP::Client.new(SERVER)
|
20
|
+
dsn = daap.connect
|
21
|
+
assert_equal("Aaron's Music", dsn)
|
23
22
|
end
|
24
|
-
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def test_connect_with_block
|
25
|
+
daap = Net::DAAP::Client.new(SERVER)
|
26
|
+
daap.connect do |dsn|
|
27
|
+
assert_equal("Aaron's Music", dsn)
|
28
|
+
end
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
33
|
-
daap =
|
34
|
-
|
35
|
-
|
31
|
+
def test_db_error
|
32
|
+
daap = Net::DAAP::Client.new(SERVER)
|
33
|
+
begin
|
34
|
+
daap.databases
|
35
|
+
rescue
|
36
|
+
assert(true, true)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
def test_songs
|
39
41
|
songs = @daap.databases[0].songs
|
40
42
|
songs_hash = Hash.new
|
41
43
|
songs.each do |song|
|
42
|
-
songs_hash[song.id] = { :size => song.size, :album => song.album,
|
43
|
-
:name => song.name, :artist => song.artist, :format => song.format,
|
44
|
+
songs_hash[song.id] = { :size => song.size, :album => song.album.to_s,
|
45
|
+
:name => song.name, :artist => song.artist.to_s, :format => song.format,
|
44
46
|
:persistentid => song.persistentid, :itemid => song.id }
|
45
47
|
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
2327245=>{:itemid=>2327245, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>5212004, :name=>"Gagging Order", :persistentid=>2327245},
|
62
|
-
2327283=>{:itemid=>2327283, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>4833826, :name=>"A Wolf At The Door", :persistentid=>2327283},
|
63
|
-
2327226=>{:itemid=>2327226, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>4134912, :name=>"Sail To The Moon", :persistentid=>2327226},
|
64
|
-
2327264=>{:itemid=>2327264, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>2350164, :name=>"Fitter Happier", :persistentid=>2327264},
|
65
|
-
2327312=>{:itemid=>2327312, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>2868372, :name=>"I Will", :persistentid=>2327312},
|
66
|
-
2327246=>{:itemid=>2327246, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>5130084, :name=>"I am Citizen Insane", :persistentid=>2327246},
|
67
|
-
2327284=>{:itemid=>2327284, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>4785551, :name=>"2 + 2 = 5", :persistentid=>2327284},
|
68
|
-
2327322=>{:itemid=>2327322, :album=>"I Might Be Wrong: Live Recordings", :format=>"mp3", :artist=>"Radiohead", :size=>5953983, :name=>"The National Anthem", :persistentid=>2327322},
|
69
|
-
2327227=>{:itemid=>2327227, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>3223552, :name=>"A Wolf At The Door", :persistentid=>2327227},
|
70
|
-
2327265=>{:itemid=>2327265, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>4616547, :name=>"Electioneering", :persistentid=>2327265},
|
71
|
-
2327303=>{:itemid=>2327303, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>6475455, :name=>"There There (The Boney King Of Nowhere)", :persistentid=>2327303},
|
72
|
-
2327294=>{:itemid=>2327294, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>7122152, :name=>"We Suck Young Blood", :persistentid=>2327294},
|
73
|
-
2327237=>{:itemid=>2327237, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>3229696, :name=>"Scatterbrain", :persistentid=>2327237},
|
74
|
-
2327247=>{:itemid=>2327247, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>3349578, :name=>"Fog. (Again) - Live", :persistentid=>2327247},
|
75
|
-
2327285=>{:itemid=>2327285, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>5170908, :name=>"Sail To The Moon (Brush The Cobwebs Of The Sky)", :persistentid=>2327285},
|
76
|
-
2327323=>{:itemid=>2327323, :album=>"I Might Be Wrong: Live Recordings", :format=>"mp3", :artist=>"Radiohead", :size=>6263793, :name=>"Dollars And Cents", :persistentid=>2327323},
|
77
|
-
2327228=>{:itemid=>2327228, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>3225600, :name=>"Go To Sleep", :persistentid=>2327228},
|
78
|
-
2327266=>{:itemid=>2327266, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>5691739, :name=>"Airbag", :persistentid=>2327266},
|
79
|
-
2327295=>{:itemid=>2327295, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>6240049, :name=>"Sit Down. Stand Up", :persistentid=>2327295},
|
80
|
-
2327314=>{:itemid=>2327314, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>6463866, :name=>"Where I End And You Begin", :persistentid=>2327314},
|
81
|
-
2327324=>{:itemid=>2327324, :album=>"I Might Be Wrong: Live Recordings", :format=>"mp3", :artist=>"Radiohead", :size=>5300405, :name=>"Idioteque", :persistentid=>2327324},
|
82
|
-
2327229=>{:itemid=>2327229, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>5179392, :name=>"There There", :persistentid=>2327229},
|
83
|
-
2327267=>{:itemid=>2327267, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>5707428, :name=>"Climbing Up The Walls", :persistentid=>2327267},
|
84
|
-
2327305=>{:itemid=>2327305, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>4840722, :name=>"Scatterbrain", :persistentid=>2327305},
|
85
|
-
2327248=>{:itemid=>2327248, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>4547728, :name=>"I Am A Wicked Child", :persistentid=>2327248},
|
86
|
-
2327286=>{:itemid=>2327286, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>4836960, :name=>"Go To Sleep", :persistentid=>2327286},
|
87
|
-
2327258=>{:itemid=>2327258, :album=>"2+2=5 CD's", :format=>"mp3", :artist=>"Radiohead", :size=>4930333, :name=>"Remyxomatosis", :persistentid=>2327258},
|
88
|
-
2327315=>{:itemid=>2327315, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>3990668, :name=>"2+2=5 (The Lukewarm)", :persistentid=>2327315},
|
89
|
-
2327230=>{:itemid=>2327230, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>5163008, :name=>"Backdrifts", :persistentid=>2327230},
|
90
|
-
2327268=>{:itemid=>2327268, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>5299397, :name=>"Exit Music (For A Film)", :persistentid=>2327268},
|
91
|
-
2327249=>{:itemid=>2327249, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>7450123, :name=>"Remyxomatosis (Cristian Vogel RMX)", :persistentid=>2327249},
|
92
|
-
2327287=>{:itemid=>2327287, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>7767272, :name=>"There There", :persistentid=>2327287},
|
93
|
-
2327325=>{:itemid=>2327325, :album=>"I Might Be Wrong: Live Recordings", :format=>"mp3", :artist=>"Radiohead", :size=>4552253, :name=>"Like Spinning Plates", :persistentid=>2327325},
|
94
|
-
2327240=>{:itemid=>2327240, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>1912832, :name=>"I Will", :persistentid=>2327240},
|
95
|
-
2327316=>{:itemid=>2327316, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>5581763, :name=>"Myxomatosis", :persistentid=>2327316},
|
96
|
-
2327221=>{:itemid=>2327221, :album=>"There there", :format=>"mp3", :artist=>"Radiohead", :size=>5777028, :name=>"Where bluebirds fly.", :persistentid=>2327221},
|
97
|
-
2327259=>{:itemid=>2327259, :album=>"2+2=5 CD's", :format=>"mp3", :artist=>"Radiohead", :size=>7425967, :name=>"There There (demo)", :persistentid=>2327259},
|
98
|
-
2327297=>{:itemid=>2327297, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>5389293, :name=>"Where I End And You Begin (The Sky Is Falling In)", :persistentid=>2327297},
|
99
|
-
2327269=>{:itemid=>2327269, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>5195935, :name=>"Lucky", :persistentid=>2327269},
|
100
|
-
2327307=>{:itemid=>2327307, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>7137199, :name=>"A Punchup At A Wedding", :persistentid=>2327307},
|
101
|
-
2327250=>{:itemid=>2327250, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>11222064, :name=>"There there (First demo)", :persistentid=>2327250},
|
102
|
-
2327231=>{:itemid=>2327231, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>4749312, :name=>"We Suck Young Blood", :persistentid=>2327231},
|
103
|
-
2327260=>{:itemid=>2327260, :album=>"2+2=5 CD's", :format=>"mp3", :artist=>"Radiohead", :size=>4263688, :name=>"Skttrbrain (Four Tet RMX)", :persistentid=>2327260},
|
104
|
-
2327298=>{:itemid=>2327298, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>5937853, :name=>"We Suck Young Blood (Your Time Is Up)", :persistentid=>2327298},
|
105
|
-
2327251=>{:itemid=>2327251, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>5786001, :name=>"Paperbag Writer", :persistentid=>2327251},
|
106
|
-
2327232=>{:itemid=>2327232, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>3393536, :name=>"The Gloaming", :persistentid=>2327232},
|
107
|
-
2327270=>{:itemid=>2327270, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>6494227, :name=>"The Tourist", :persistentid=>2327270},
|
108
|
-
2327280=>{:itemid=>2327280, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>6201806, :name=>"Sail To The Moon", :persistentid=>2327280},
|
109
|
-
2327261=>{:itemid=>2327261, :album=>"2+2=5 CD's", :format=>"mp3", :artist=>"Radiohead", :size=>2158009, :name=>"I will (LA version)", :persistentid=>2327261},
|
110
|
-
2327299=>{:itemid=>2327299, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>5089617, :name=>"The Gloaming", :persistentid=>2327299},
|
111
|
-
2327242=>{:itemid=>2327242, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>4311040, :name=>"Where I End And You Begin", :persistentid=>2327242},
|
112
|
-
2327271=>{:itemid=>2327271, :album=>"OK Computer", :format=>"mp3", :artist=>"Radiohead", :size=>5989015, :name=>"Let Down", :persistentid=>2327271},
|
113
|
-
2327233=>{:itemid=>2327233, :album=>"Hail To The Theif", :format=>"mp3", :artist=>"Radiohead", :size=>4161536, :name=>"Sit Down, Stand Up", :persistentid=>2327233},
|
114
|
-
2327252=>{:itemid=>2327252, :album=>"Radiohead - HTTT Era B-Sides", :format=>"m4a", :artist=>"Radiohead", :size=>6588253, :name=>"Where Bluebirds Fly", :persistentid=>2327252},
|
115
|
-
2327290=>{:itemid=>2327290, :album=>"Hail To The Thief", :format=>"mp3", :artist=>"Radiohead", :size=>7743448, :name=>"Backdrifts", :persistentid=>2327290}}
|
116
|
-
assert_equal(hash, songs_hash)
|
49
|
+
assert_equal(HASH, songs_hash)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_songs_with_block
|
53
|
+
@daap.databases do |db|
|
54
|
+
songs_hash = Hash.new
|
55
|
+
db.songs do |song|
|
56
|
+
songs_hash[song.id] = { :size => song.size, :album => song.album.to_s,
|
57
|
+
:name => song.name, :artist => song.artist.to_s, :format => song.format,
|
58
|
+
:persistentid => song.persistentid, :itemid => song.id }
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_equal(HASH, songs_hash)
|
62
|
+
end
|
117
63
|
end
|
118
64
|
|
119
65
|
def test_databases
|
@@ -121,28 +67,13 @@ class DAAPClient_Test < Test::Unit::TestCase
|
|
121
67
|
assert(true, @daap.databases.length == 1)
|
122
68
|
db = @daap.databases[0]
|
123
69
|
assert_equal(1, db.persistentid)
|
124
|
-
assert_equal('
|
125
|
-
assert_equal(
|
70
|
+
assert_equal('Aaron\'s Music', db.name)
|
71
|
+
assert_equal(3, db.containercount)
|
126
72
|
assert_equal(1, db.id)
|
127
|
-
assert_equal(
|
128
|
-
assert_equal(
|
73
|
+
assert_equal(26, db.itemcount)
|
74
|
+
assert_equal(26, db.songs.length)
|
129
75
|
assert(true, db.songs.length == db.itemcount)
|
130
|
-
assert_equal(
|
76
|
+
assert_equal(3, db.playlists.length)
|
131
77
|
assert(true, db.playlists.length == db.containercount)
|
132
|
-
|
133
|
-
#@daap.databases.each do |db|
|
134
|
-
# puts "All songs in the database"
|
135
|
-
# db.songs.each do |song|
|
136
|
-
# #puts "#{song.artist} - #{song.name}"
|
137
|
-
# end
|
138
|
-
#
|
139
|
-
# puts "Songs for each playlist"
|
140
|
-
# db.playlists.each do |pl|
|
141
|
-
# puts "Playlist name: #{pl.name}"
|
142
|
-
# pl.songs.each do |song|
|
143
|
-
# #puts "#{song.artist} - #{song.name}"
|
144
|
-
# end
|
145
|
-
# end
|
146
|
-
#end
|
147
78
|
end
|
148
79
|
end
|