line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::iTMS; |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Written by Thomas R. Sibley, |
4
|
|
|
|
|
|
|
# |
5
|
1
|
|
|
1
|
|
48788
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
51
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
88
|
|
9
|
|
|
|
|
|
|
$VERSION = '0.15'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
561
|
use Net::iTMS::Error; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
12
|
1
|
|
|
1
|
|
756
|
use Net::iTMS::Request; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Net::iTMS::Artist; |
14
|
|
|
|
|
|
|
use Net::iTMS::Album; |
15
|
|
|
|
|
|
|
use Net::iTMS::Song; |
16
|
|
|
|
|
|
|
use Net::iTMS::Genre; |
17
|
|
|
|
|
|
|
use Net::iTMS::Search; |
18
|
|
|
|
|
|
|
use Net::iTMS::Search::Advanced; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Net::iTMS - Interface to the information within the iTunes Music Store (iTMS) |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $iTMS = Net::iTMS->new; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $artist = $iTMS->get_artist(2893902); |
29
|
|
|
|
|
|
|
print "Artist: ", $artist->name, "\n"; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
for my $album ($artist->discography) { |
32
|
|
|
|
|
|
|
print $album->title, "\n"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
for my $track ($album->tracks) { |
35
|
|
|
|
|
|
|
print "\t ", $track->number, ": ", $track->title, "\n"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Net::iTMS is the main class (that is, the one you should be using) for |
42
|
|
|
|
|
|
|
interacting with Apple's iTunes Music Store (L). |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Currently, it provides means to access individual artist, album, and song |
45
|
|
|
|
|
|
|
information in the iTMS. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Methods |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
All methods return C on error and (should) set an error message, |
50
|
|
|
|
|
|
|
which is available through the C method. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 12 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item C<< new(debug => 1, ...) >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Takes an argument list of optional C value> pairs. The options available |
57
|
|
|
|
|
|
|
are: |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over 24 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item C<< debug => 0 or 1 >> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
If set to a true value, debug messages to be printed to STDERR. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C<< show_xml => 0 or 1 >> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
If set to a true value, L will print to STDERR the XML |
68
|
|
|
|
|
|
|
fetched during each request. The C option must also be set to true |
69
|
|
|
|
|
|
|
for the XML to print. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns a blessed hashref (object) for Net::iTMS. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
sub new { |
77
|
|
|
|
|
|
|
my ($class, %opt) = @_; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return bless { |
80
|
|
|
|
|
|
|
error => '', |
81
|
|
|
|
|
|
|
debug => defined $opt{debug} ? $opt{debug} : 0, |
82
|
|
|
|
|
|
|
_request => Net::iTMS::Request->new(%opt), |
83
|
|
|
|
|
|
|
}, $class; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item C |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Takes an artistId and returns a L object. |
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
sub get_artist { |
91
|
|
|
|
|
|
|
my ($self, $id, %opt) = @_; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return $id |
94
|
|
|
|
|
|
|
? Net::iTMS::Artist->new($self, $id, %opt) |
95
|
|
|
|
|
|
|
: $self->_set_error('No artist ID passed.'); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item C |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Takes a genreId and returns a L object. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
sub get_genre { |
104
|
|
|
|
|
|
|
my ($self, $id, %opt) = @_; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $id |
107
|
|
|
|
|
|
|
? Net::iTMS::Genre->new($self, $id, %opt) |
108
|
|
|
|
|
|
|
: $self->_set_error('No artist ID passed.'); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item C |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Takes an albumId and returns a L object. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
sub get_album { |
117
|
|
|
|
|
|
|
my ($self, $id, %opt) = @_; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
return $id |
120
|
|
|
|
|
|
|
? Net::iTMS::Album->new($self, $id, %opt) |
121
|
|
|
|
|
|
|
: $self->_set_error('No album ID passed.'); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item C |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Takes a songId and returns a L object. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
sub get_song { |
130
|
|
|
|
|
|
|
my ($self, $id, %opt) = @_; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return $id |
133
|
|
|
|
|
|
|
? Net::iTMS::Song->new($self, $id, %opt) |
134
|
|
|
|
|
|
|
: $self->_set_error('No song ID passed.'); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item C |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
If C<$query> is a hashref, this method executes an advanced search using the |
140
|
|
|
|
|
|
|
hashref and returns a L object. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Otherwise, this method assumes C<$query> to be a string and executes a simple |
143
|
|
|
|
|
|
|
search using the string and returns a L object. |
144
|
|
|
|
|
|
|
PLEASE NOTE: This simple search does not work at this time due to unresolvable |
145
|
|
|
|
|
|
|
changes in the iTMS. Use the advanced search functionality instead. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
sub search_for { |
149
|
|
|
|
|
|
|
my ($self, $query, %opt) = @_; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
return $self->_set_error('No query passed.') |
152
|
|
|
|
|
|
|
if not $query; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
return ref $query eq 'HASH' |
155
|
|
|
|
|
|
|
? Net::iTMS::Search::Advanced->new($self, $query, %opt) |
156
|
|
|
|
|
|
|
: Net::iTMS::Search->new($self, $query, %opt); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 TODO |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Net::iTMS::Genre |
164
|
|
|
|
|
|
|
* browse, etc |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Net::iTMS::Album |
167
|
|
|
|
|
|
|
* browseAlbum URL... see what information |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Net::iTMS::Song |
170
|
|
|
|
|
|
|
* songMetaData... how to use this? keep getting server errors |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Programmatic tests, instead of hand testing by me. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Improved caching (more selective updates) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Redo SYNOPSISes |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 BUGS |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
All bugs, open and resolved, are handled by RT at |
181
|
|
|
|
|
|
|
L. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Please report all bugs via |
184
|
|
|
|
|
|
|
L. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 LICENSE |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Copyright 2004, Thomas R. Sibley. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
You may use, modify, and distribute this package under the same terms as Perl itself. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 AUTHOR |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Thomas R. Sibley, L |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
42; |