line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MP3::Mplib; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
263066
|
use 5.005003; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
181
|
|
4
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
153
|
|
5
|
5
|
|
|
5
|
|
4936
|
use Errno; |
|
5
|
|
|
|
|
7723
|
|
|
5
|
|
|
|
|
274
|
|
6
|
5
|
|
|
5
|
|
33
|
use Carp; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
444
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
require DynaLoader; |
10
|
5
|
|
|
5
|
|
5224
|
use AutoLoader; |
|
5
|
|
|
|
|
8644
|
|
|
5
|
|
|
|
|
30
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
179
|
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION $AUTOLOAD); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1833
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@ISA = qw(Exporter DynaLoader); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
17
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
18
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# This allows declaration use MP3::Mplib ':all'; |
21
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
22
|
|
|
|
|
|
|
# will save memory. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
@EXPORT = qw( |
25
|
|
|
|
|
|
|
MP_EERROR |
26
|
|
|
|
|
|
|
MP_EFCOMPR |
27
|
|
|
|
|
|
|
MP_EFENCR |
28
|
|
|
|
|
|
|
MP_EFNF |
29
|
|
|
|
|
|
|
MP_EVERSION |
30
|
|
|
|
|
|
|
ISO_8859_1 |
31
|
|
|
|
|
|
|
UTF16 |
32
|
|
|
|
|
|
|
UTF16BE |
33
|
|
|
|
|
|
|
UTF8 |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
37
|
|
|
|
|
|
|
'constants' => [ qw( |
38
|
|
|
|
|
|
|
MP_ALBUM |
39
|
|
|
|
|
|
|
MP_ARTIST |
40
|
|
|
|
|
|
|
MP_COMMENT |
41
|
|
|
|
|
|
|
MP_EERROR |
42
|
|
|
|
|
|
|
MP_EFCOMPR |
43
|
|
|
|
|
|
|
MP_EFENCR |
44
|
|
|
|
|
|
|
MP_EFNF |
45
|
|
|
|
|
|
|
MP_EVERSION |
46
|
|
|
|
|
|
|
MP_GENRE |
47
|
|
|
|
|
|
|
MP_TITLE |
48
|
|
|
|
|
|
|
MP_TRACK |
49
|
|
|
|
|
|
|
MP_YEAR), @EXPORT ], |
50
|
|
|
|
|
|
|
'functions' => [ qw( |
51
|
|
|
|
|
|
|
get_header |
52
|
|
|
|
|
|
|
get_tag |
53
|
|
|
|
|
|
|
get_id3v2_header |
54
|
|
|
|
|
|
|
set_tag |
55
|
|
|
|
|
|
|
delete_tags |
56
|
|
|
|
|
|
|
clean_up |
57
|
|
|
|
|
|
|
dump_structure), @EXPORT ], |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$EXPORT_TAGS{ 'all' } = [ @{ $EXPORT_TAGS{'constants'} }, |
61
|
|
|
|
|
|
|
@{ $EXPORT_TAGS{'functions'} }, |
62
|
|
|
|
|
|
|
@EXPORT ]; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
@EXPORT_OK = ( @{ $EXPORT_TAGS{'constants'} }, |
65
|
|
|
|
|
|
|
@{ $EXPORT_TAGS{'functions'} } ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$VERSION = '0.02'; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub AUTOLOAD { |
71
|
|
|
|
|
|
|
# This AUTOLOAD is used to 'autoload' constants from the constant() |
72
|
|
|
|
|
|
|
# XS function. If a constant is not found then control is passed |
73
|
|
|
|
|
|
|
# to the AUTOLOAD in AutoLoader. |
74
|
|
|
|
|
|
|
|
75
|
20
|
|
|
20
|
|
3843
|
my $constname; |
76
|
20
|
|
|
|
|
94
|
($constname = $AUTOLOAD) =~ s/.*:://; |
77
|
20
|
50
|
|
|
|
58
|
croak "& not defined" if $constname eq 'constant'; |
78
|
20
|
100
|
|
|
|
748
|
my $val = constant($constname, @_ ? $_[0] : 0); |
79
|
20
|
50
|
|
|
|
74
|
if ($! != 0) { |
80
|
0
|
0
|
|
|
|
0
|
if ($!{EINVAL}) { |
81
|
0
|
|
|
|
|
0
|
$AutoLoader::AUTOLOAD = $AUTOLOAD; |
82
|
0
|
|
|
|
|
0
|
goto &AutoLoader::AUTOLOAD; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
0
|
|
|
|
|
0
|
croak "Your vendor has not defined MP3::Mplib macro $constname"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
5
|
|
|
5
|
|
31
|
{ no strict 'refs'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
5583
|
|
|
20
|
|
|
|
|
19
|
|
90
|
20
|
|
|
28
|
|
153
|
*$AUTOLOAD = sub { $val }; |
|
28
|
|
|
|
|
2308
|
|
91
|
|
|
|
|
|
|
} |
92
|
20
|
|
|
|
|
62
|
goto &$AUTOLOAD; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
bootstrap MP3::Mplib $VERSION; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Preloaded methods go here. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
MP3::Mplib - Speedy access to id3v1 and id3v2 tags |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SYNOPSIS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use MP3::Mplib; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $mp3 = MP3::Mplib->new("/path/to/file.mp3"); |
110
|
|
|
|
|
|
|
my $v1tag = $mp3->get_v1tag; |
111
|
|
|
|
|
|
|
my $v2tag = $mp3->get_v2tag; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
while (my ($key, $val) = each %$v1tag) { |
114
|
|
|
|
|
|
|
print "$key: $val\n"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
while (my ($key, $val) = each %$v2tag) { |
118
|
|
|
|
|
|
|
... |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$mp3->add_to_v2tag( { TYER => 2002 } ); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DESCRIPTION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
MP3::Mplib is a wrapper around Stefan Podkowinski's mplib written in C. It combines the best of both worlds: C's speed and Perl's nice object-orientedness. Note that B ships with its own version of mplib (currently 1.0.1). |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
There is no sophistaced class hierarchy. You simply create a B object. Each method either returns a native Perl data-structure or takes one. Bang. That's it. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 METHODS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item B |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Constructor that takes a filename as only argument. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $mp3_object = MP3::Mplib->new("file.mp3"); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub new { |
144
|
5
|
|
|
5
|
1
|
467
|
my ($class, $file) = @_; |
145
|
5
|
|
33
|
|
|
36
|
$class = ref($class) || $class; |
146
|
5
|
|
|
|
|
35
|
my $self = { _mp_file => $file, |
147
|
|
|
|
|
|
|
_mp_id3v1 => undef, |
148
|
|
|
|
|
|
|
_mp_id3v2 => undef, |
149
|
|
|
|
|
|
|
_mp_header => undef, |
150
|
|
|
|
|
|
|
_mp_v2header => undef,}; |
151
|
5
|
|
|
|
|
26
|
bless $self => $class; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=pod |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over 4 |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item B |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Returns a hash-ref to the mpeg-header. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $mpeg_header = $mp3->header; |
163
|
|
|
|
|
|
|
print $mpeg_header->{bitrate}, "\n"; |
164
|
|
|
|
|
|
|
... |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The hash-ref contains the following fields: |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=over 8 |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * I (integer) |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item * I (string) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * I (string) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * I (boolean) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * I (string) |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * I (string) |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * I (boolean) |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * I (boolean) |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * I (string) |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * I (boolean) |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * I (boolean) |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * I (boolean) |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * I (boolean) |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=back |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Z<> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub header { |
205
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
206
|
0
|
|
0
|
|
|
0
|
return ($self->{_mp_header} ||= get_header($self->{_mp_file})); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=pod |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over 4 |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item B |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Returns the id3v1 tag as a hash-ref. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $tag = $mp3->get_v1tag; |
218
|
|
|
|
|
|
|
print $tag->{title}, "\n"; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
The hash-ref contains the following fields: |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=over 8 |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item * I |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item * I |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * I |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * I |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * I |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item * I |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * I |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=back |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=back |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Z<> |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=cut |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub get_v1tag { |
247
|
4
|
|
|
4
|
1
|
14
|
my $self = shift; |
248
|
4
|
|
100
|
|
|
700
|
return ($self->{_mp_id3v1} ||= get_tag($self->{_mp_file}, 1) |
|
|
|
33
|
|
|
|
|
249
|
|
|
|
|
|
|
|| { } ); |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=pod |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=over 4 |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item B |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Returns the id3v2 tag as a hash-ref. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
my $tag = $mp3->get_v2tag; |
261
|
|
|
|
|
|
|
print $tag->{TIT1}, "\n"; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
The hash-ref returned can contain up to 74 fields. All but the "COMM" and "WXXX" field have a single value if present. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
The "COMM" field is the id3v2-equivalent of the 'comment' tag and contains three sub-categories: |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=over 8 |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item * I |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
The actual comment as an arbitrarily long text. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item * I |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
A short description of the comment. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=item * I |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
The language of the comment as 3-byte string, e.g. "ENG" for English or "GER" for German. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=back |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
The "WXXX" field looks like this: |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=over 8 |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item * I |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
The URL that is referenced. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item * I |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
An additional description. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=back |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=back |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Example: |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
my $tag = $mp3->get_v2tag; |
302
|
|
|
|
|
|
|
if (exists $tag->{COMM}) { |
303
|
|
|
|
|
|
|
print "Language: $tag->{COMM}->{lang}\n"; |
304
|
|
|
|
|
|
|
print "Short: $tag->{COMM}->{short}\n"; |
305
|
|
|
|
|
|
|
print "Text: $tag->{COMM}->{text}\n"; |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=cut |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
sub get_v2tag { |
311
|
5
|
|
|
5
|
1
|
1524
|
my $self = shift; |
312
|
5
|
|
100
|
|
|
454
|
return ($self->{_mp_id3v2} ||= get_tag($self->{_mp_file}, 2) |
|
|
|
66
|
|
|
|
|
313
|
|
|
|
|
|
|
|| { } ); |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=pod |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=over 4 |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=item B |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
Returns a hash-ref to the id3v2 header. This can contain the following fields: |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=over 8 |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=item * I |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
The 'x' as in 2.x.1 |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=item * I |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
The 'x' as in 2.3.x |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=item * I |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=item * I |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=item * I |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=item * I |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=item * I |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
A reference to the extended header if present. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=back |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
The extended header has the following fields: |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=over 8 |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=item * I |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=item * I |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=item * I |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=item * I |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=item * I |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=item * I |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=item * I |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=item * I |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=item * I |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
=item * I |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=back |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
Since the extended header field only exists when the MP3 file has such a header, check for existance before accessing it: |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
my $header = $mp3->get_v2header; |
377
|
|
|
|
|
|
|
if (exists $header->{extended_header}) { |
378
|
|
|
|
|
|
|
print $header->{extended_header}->{size}, "\n"; |
379
|
|
|
|
|
|
|
... |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=back |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=cut |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub get_v2header { |
387
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
388
|
0
|
|
0
|
|
|
0
|
return ($self->{_mp_v2header} ||= get_id3v2_header($self->{_mp_file}) |
|
|
|
0
|
|
|
|
|
389
|
|
|
|
|
|
|
|| { } ); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=pod |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=over 4 |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=item B |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
Sets the id3v1-tag. If there was no such tag previously, it is created. An existing one is replaced. |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
It takes one obligatory argument, namely a reference to a hash. This hash has the keys described in C. |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
'encoding' is an optional argument that determines the character encoding used for the data. It is either of the constants ISO_8859_1, UTF16, UTF16BE or UTF8. If none is given, ISO_8859_1 is used. |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
$mp3->set_v1tag( { title => 'Help', |
405
|
|
|
|
|
|
|
artist => 'The Beatles', |
406
|
|
|
|
|
|
|
track => 1, |
407
|
|
|
|
|
|
|
year => 1966, |
408
|
|
|
|
|
|
|
genre => 'Oldies', |
409
|
|
|
|
|
|
|
comment => 'A Beatles-song', }, &UTF16 ); |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
Returns a true value on success, false otherwise. In this case, check C<$mp3-Eerror>. |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=back |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=cut |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
sub set_v1tag { |
418
|
3
|
|
|
3
|
1
|
1203
|
my ($self, $tag, $enc) = @_; |
419
|
|
|
|
|
|
|
|
420
|
3
|
50
|
|
|
|
15
|
croak "MP3::Mplib::set_v1tag expects a hash-ref as first argument" |
421
|
|
|
|
|
|
|
if ref $tag ne 'HASH'; |
422
|
|
|
|
|
|
|
|
423
|
3
|
100
|
33
|
|
|
46
|
if (set_tag($self->{_mp_file}, 1, $tag, $enc || &ISO_8859_1)) { |
424
|
|
|
|
|
|
|
# forces re-parsing on next get_v1header |
425
|
1
|
|
|
|
|
8
|
undef $self->{_mp_id3v1}; |
426
|
1
|
|
|
|
|
7
|
return 1; |
427
|
|
|
|
|
|
|
} |
428
|
2
|
|
|
|
|
9
|
return; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=pod |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=over 4 |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=item B |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
Adds (or rather merges) 'tag' with the currently existing id3v1-tag. Existing fields are replaced. Use this to add a field to an already existing tag. 'tag' is meant to be a hash-reference: |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
$mp3->add_to_v1tag( { TITLE => 'some title', |
440
|
|
|
|
|
|
|
ALBUM => 'some album', } ); |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
Returns a true value on success, false otherwise in which case you should check C<$mp3-Eerror>. |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=back |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=cut |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub add_to_v1tag { |
449
|
0
|
|
|
0
|
1
|
0
|
my ($self, $tag, $enc) = @_; |
450
|
|
|
|
|
|
|
|
451
|
0
|
0
|
|
|
|
0
|
croak "MP3::Mplib::add_to_v1tag expects a hash-ref as first argument" |
452
|
|
|
|
|
|
|
if ref $tag ne 'HASH'; |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
0
|
my %old_tag = %{ $self->get_v1tag }; |
|
0
|
|
|
|
|
0
|
|
455
|
|
|
|
|
|
|
|
456
|
0
|
0
|
0
|
|
|
0
|
if (set_tag($self->{_mp_file}, 1, |
457
|
|
|
|
|
|
|
{ %old_tag, %$tag }, $enc || &ISO_8859_1)) { |
458
|
0
|
|
|
|
|
0
|
undef $self->{_mp_id3v1}; |
459
|
0
|
|
|
|
|
0
|
return 1; |
460
|
|
|
|
|
|
|
} |
461
|
0
|
|
|
|
|
0
|
return; |
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
=pod |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=over 4 |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=item B |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
Sets the id3v2 tag. This has the same semantics as C, so read its description first. |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
It differs in that id3v2 tags have different field names. They are always four ccharacter long uppercased strings. Since there are 74 of them, their explanation is not included in here. Please see the specifications at B. |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
A number of fields are special in that they don't just take one value. You can pass a hash-ref to them instead: |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
=over 8 |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=item * I [comment field] |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
Possible fields are I<'text'>, I<'short'> and I<'lang'>. I<'lang'> is always a three character upper-case string. When just an ordinary string is passed, this will become I<'text'>. I<'short'> will be left empty in this case and I<'lang'> is set to 'ENG'. |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=item * I [used defined link frame] |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
Possible fields are I<'url'> and I<'description'>. The content of I<'url'> has to be a ISO-8859-1 encoded string regardless of which 'encoding' you passed to C. When just an ordinary string is passed, this will become I<'url'>. I<'description'> will remain empty in this case. |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=back |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
Further examples: |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
my $tag = { TIT2 => 'Help', |
491
|
|
|
|
|
|
|
COMM => { lang => 'ENG', |
492
|
|
|
|
|
|
|
text => 'Long comment ...', |
493
|
|
|
|
|
|
|
short => 'short description', }, |
494
|
|
|
|
|
|
|
WXXX => 'http://www.beatles.com', |
495
|
|
|
|
|
|
|
TEXT => 'Paul McCartney', # the text writer |
496
|
|
|
|
|
|
|
TPE1 => 'Paul McCartney', # the lead performer |
497
|
|
|
|
|
|
|
TPE2 => 'The Beatles', # the band |
498
|
|
|
|
|
|
|
..., }; |
499
|
|
|
|
|
|
|
$mp3->set_v2header($tag); |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
In the above, the I<'WXXX'> could have also looked like this: |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
WXXX => { url => 'http://www.beatles.com', |
504
|
|
|
|
|
|
|
description => 'a webpage', }, |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
or somesuch. |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
This method has the same return values as C. |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=back |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=cut |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
sub set_v2tag { |
515
|
1
|
|
|
1
|
1
|
1993
|
my ($self, $tag, $enc) = @_; |
516
|
|
|
|
|
|
|
|
517
|
1
|
50
|
|
|
|
4
|
croak "MP3::Mplib::set_v2tag expects a hash-ref as first argument" |
518
|
|
|
|
|
|
|
if ref $tag ne 'HASH'; |
519
|
|
|
|
|
|
|
|
520
|
1
|
50
|
33
|
|
|
5
|
if (set_tag($self->{_mp_file}, 2, $tag, $enc || &ISO_8859_1)) { |
521
|
|
|
|
|
|
|
# forces re-parsing on next get_v2header |
522
|
1
|
|
|
|
|
2
|
undef $self->{_mp_id3v2}; |
523
|
1
|
|
|
|
|
4
|
return 1; |
524
|
|
|
|
|
|
|
} |
525
|
0
|
|
|
|
|
0
|
return; |
526
|
|
|
|
|
|
|
} |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=pod |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
=over 4 |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=item B |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
The id3v2 equivalent to C. It has the same semantics, both regarding the arguments it gets as well as its return value. |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=back |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=cut |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
sub add_to_v2tag { |
541
|
1
|
|
|
1
|
1
|
2
|
my ($self, $tag, $enc) = @_; |
542
|
1
|
50
|
|
|
|
4
|
croak "MP3::Mplib::add_to_v2tag expects a hash-ref as first argument" |
543
|
|
|
|
|
|
|
if ref $tag ne 'HASH'; |
544
|
|
|
|
|
|
|
|
545
|
1
|
|
|
|
|
2
|
my %oldtag = %{ $self->get_v2tag }; |
|
1
|
|
|
|
|
2
|
|
546
|
|
|
|
|
|
|
|
547
|
1
|
50
|
33
|
|
|
11
|
if (set_tag($self->{_mp_file}, 2, |
548
|
|
|
|
|
|
|
{ %oldtag, %$tag }, $enc || &ISO_8859_1)) { |
549
|
1
|
|
|
|
|
3
|
undef $self->{_mp_id3v2}; |
550
|
1
|
|
|
|
|
12
|
return 1; |
551
|
|
|
|
|
|
|
} |
552
|
0
|
|
|
|
|
0
|
return; |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=pod |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=over 4 |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=item B |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
Deletes the id3v2 tag from the file. |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
=back |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=cut |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
sub del_v1tag { |
569
|
1
|
|
|
1
|
1
|
821
|
my $self = shift; |
570
|
1
|
50
|
|
|
|
197
|
if (delete_tags($self->{_mp_file}, 1)) { |
571
|
1
|
|
|
|
|
8
|
undef $self->{_mp_id3v1}; |
572
|
1
|
|
|
|
|
8
|
return 1; |
573
|
|
|
|
|
|
|
} |
574
|
0
|
|
|
|
|
0
|
return 0; |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=pod |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=over 4 |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=item B |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
Deletes the id3v2 tag. Correctly speaking, it deletes I id3v2 tags in the file. But since B does not allow access to particular id3v2 tags this distinction should not matter. |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=back |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=cut |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
sub del_v2tag { |
590
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
591
|
1
|
50
|
|
|
|
946
|
if (delete_tags($self->{_mp_file}, 2)) { |
592
|
1
|
|
|
|
|
3
|
undef $self->{_mp_id3v2}; |
593
|
1
|
|
|
|
|
6
|
return 1; |
594
|
|
|
|
|
|
|
} |
595
|
0
|
|
|
|
|
0
|
return 0; |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=pod |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=over 4 |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
=item B |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
Some MP3s may have a very extensive id3v2-tag with some fields showing up several times. If you don't like that, use this method to wipe out all but the first frame of each type. |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
This method doesn't return anything meaningful since it never fails. |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=back |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=cut |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
sub clean_up { |
613
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
614
|
0
|
|
|
|
|
0
|
_clean_up($self->{_mp_file}); |
615
|
0
|
|
|
|
|
0
|
return 1; |
616
|
|
|
|
|
|
|
} |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=pod |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=over 4 |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=item B |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
Mainly used as a debugging tool (or if you are just curious to peek at all the tags and fields present in an MP3), this method dumps the tag-structure of the MP3 to STDOUT. |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
This method doesn't return anything meaningful since it never fails. |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=back |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
=cut |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
sub dump_structure { |
633
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
634
|
0
|
|
|
|
|
0
|
_dump_structure($self->{_mp_file}); |
635
|
0
|
|
|
|
|
0
|
return 1; |
636
|
|
|
|
|
|
|
} |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=pod |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
=over 4 |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
=item B |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
As always, things can get wrong on certain operations. The statement that did not perform as expected always returns a false value in which case this functions returns a reference to a hash that you can inspect further. Keys of the hash are field names of an id3-tag while the corresponding values are set to an error-code (see L). |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
There is a special key: I relates to the file rather than to an individual tag-field. This might be set when you try to write a new tag on a read-only file. |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
Note that C can be called either as instance-method, class-method or function: |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
my %err = $mp3->error; |
651
|
|
|
|
|
|
|
my %err = MP3::Mplib->error; |
652
|
|
|
|
|
|
|
my %err = MP3::Mplib::error(); |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
It is not exported so you have to qualify it when calling it as function. |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=back |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=cut |
659
|
|
|
|
|
|
|
|
660
|
2
|
|
50
|
2
|
1
|
20
|
sub error { return { split /\034/, $MP3::Mplib::Error || '' } } |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
=head1 EXPORTS |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=head2 Default exports |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
B exports a couple of constants by default. If you don't want them, include the module in your scripts like this: |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
use MP3::Mplib (); |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
Please note that each of these constants has to be called as subroutine, either with empty trailing paranteses or a leading ampersand: |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
my $c = ISO_8859_1; # NOT OK! |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
# instead: |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
my $c = &ISO_8859_1; |
677
|
|
|
|
|
|
|
# or |
678
|
|
|
|
|
|
|
my $c = ISO_8859_1(); |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=over 4 |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
=item B |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=over 8 |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=item * I |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=item * I |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=item * I |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=item * I |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
=back |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
Z<> |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=item B |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=over 8 |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=item * I |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
This is a non-specific error code that is - according to the mplib.h - returned under circumstances that cannot happen. :-) |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=item * I |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
The specified field does not exist in the tag. |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=item * I |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
The value for this field has been compressed and can thus not be retrieved. |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=item * I |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
The value for this field has been encrypted and can thus not be retrieved. |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
=item * I |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
Tag has a version set that is not supported by the library. |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=back |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=back |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
=head2 Optional exports |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
B has a couple of tags you can import: |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
use MP3::Mplib qw(:constants) |
731
|
|
|
|
|
|
|
use MP3::Mplib qw(:functions) |
732
|
|
|
|
|
|
|
use MP3::Mplib qw(:all) |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=over 4 |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=item B<:constants> |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
This exports additional constants used for identifying id3v1 tag fields. These are integers so you B use them as hash-keys for C or get C! |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
=over 8 |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
=item * I |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
=item * I |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
=item * I |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
=item * I |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=item * I |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=item * I |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=item * I |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=back |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
Z<> |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
=item B<:functions> |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
Seven functions are exported by this tag. Use those when you want the functional interface: |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=over 8 |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=item * I |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
=item * I |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
=item * I |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
=item * I |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
=item * I |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=item * I |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
=item * I |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=back |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
For a description see L. |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=back |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=head1 FUNCTIONS |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
When using the functional interface, you are using directly the functions defined through XS code. All of them have a prototype so that you can safely omit the parens when using them. |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
=over 4 |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=item B |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
Returns a hash-ref to the mpeg-header. Fields are described under C |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
=item B |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
Returns a hash-ref to the id3-tag for the given C<$file>. C<$version> must either be 1 or 2. |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
Returns undef if no tag of the specified C<$version> has been found. |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
=item B |
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
Returns a hash-ref to the id3v2-header for the given C<$file>. Fields are described under C in L<"METHODS">. |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
=item B |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
Sets the tag of C<$version> for C<$file> to C<$tag> which has to be a hash-reference. C<$enc> is optional but if given has to be one of the constants described under "Encodings" in L<"EXPORTS">. It defaults to C. |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
Returns a true value on success, false otherwise. Check C in this case. |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
=item B |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
Deletes all tags of C<$version> in C<$file>. |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
Returns a true value on success false otherwise. Currently C is B set when this functions fails. |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
=item B |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
Cleans up the id3v2-tag of C<$file>. See C in L<"METHODS"> for details. |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
=item B |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
Dumps the tag-structure of C<$file> to STDOUT. See C in L<"METHODS"> for details. |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
=back |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
=head1 PLATFORMS |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
=over 4 |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
=item B |
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
My development environment is a Debian box. In theory I should have access to some Solaris machines in my university but forgot my login. That means it's currently just tested under Linux. |
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
I'd be grateful for anyone sending me remarks how well (or even at all) this module works on his/her machine. If someone is using ActiveState under Windows and did in fact install it succesfully I'd be even happier to hear about that. Perhaps this person would even be so kind to help me packing up a PPM package or even become the Windows-maintainer. Since I am lacking VisualC I am closed out here. |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
=item B |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
I've tested it with the following compilers and Perl versions: |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
=over 8 |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
=item * gcc 2.95.4 / Perl 5.005_03 |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
=item * gcc 2.95.4 / Perl 5.6.1 |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
=item * gcc 3.0.4 / Perl 5.8.0 |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=back |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
=back |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
=head1 KNOWN BUGS |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
The underlying C library is incomplete with respect to parsing id3v2 tags. This is ok with simple tags, like all the I frames. It is not so ok with more complicated ones, such as I. I contacted mplib's author with a request for adding missing functionality. The mplib's author said that they might be added at some other time. |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
Currently, some missing functionality has been added by me (notably support for I). |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
The current object-oriented interface could be considered a bug. There is only the C object and no separate objects for id3v1- or id3v2-tags. Adding those, however, would require additions to the XS-portion of this module. Read: A lot of additional work. |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
=head1 TODO |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
Well, see L<"KNOWN BUGS">. |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
=over 4 |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
=item B |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
Some functionality from the mplib hasn't yet been incorporated into this library: |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
=over 8 |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
=item * I |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
Converts an id3v2-tag into an id3v1-tag. |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
=item * I |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
Vice versa. |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
=item * I |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
Does some checks on an id3v1 field value. Oddly enough, there is no equivalent for id3v2 fields in the library. |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=back |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=item B |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
I would like to have support for the I frame (attached picture). Something like the following would be nice: |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
$mp3->attach($file, $description); |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
Probably much more, but I am in modest-mode right now. |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
=item B |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
Always an issue with me. Each object should have its own error reporting mechanism. |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
=item B |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
No tests yet for functional interface, nor for the header access. |
903
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
=back |
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
=head1 VERSION |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
This document describes version 0.02. |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
=head1 AUTHOR AND COPYRIGHT |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
Tassilo v. Parseval |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
Copyright (c) 2002-2004 Tassilo von Parseval. |
915
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
916
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
=head1 SEE ALSO |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
B for the id3 specifications. |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
B if you want to visit mplib's home. |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
=cut |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
1; |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
__END__ |