line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Music::Tag::FLAC; |
2
|
1
|
|
|
1
|
|
11322
|
use strict; use warnings; use utf8; |
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
54
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
9
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.4101'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Copyright © 2007,2010 Edward Allen III. Some rights reserved. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public |
8
|
|
|
|
|
|
|
# License or the Artistic License, as specified in the README file. |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1462
|
use Audio::FLAC::Header; |
|
1
|
|
|
|
|
9761
|
|
|
1
|
|
|
|
|
179
|
|
11
|
1
|
|
|
1
|
|
12
|
use base qw(Music::Tag::Generic); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
990
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub flac { |
14
|
58
|
|
|
58
|
1
|
731
|
my $self = shift; |
15
|
58
|
100
|
66
|
|
|
283
|
unless ((exists $self->{_Flac}) && (ref $self->{_Flac})) { |
16
|
2
|
50
|
|
|
|
9
|
if ($self->info->has_data('filename')) { |
17
|
2
|
|
|
|
|
97
|
$self->{_Flac} = Audio::FLAC::Header->new($self->info->get_data('filename')); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
58
|
|
|
|
|
1883
|
return $self->{_Flac}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our %tagmap = ( |
24
|
|
|
|
|
|
|
TITLE => 'title', |
25
|
|
|
|
|
|
|
TRACKNUMBER => 'track', |
26
|
|
|
|
|
|
|
TRACKTOTAL => 'totaltracks', |
27
|
|
|
|
|
|
|
ARTIST => 'artist', |
28
|
|
|
|
|
|
|
ALBUM => 'album', |
29
|
|
|
|
|
|
|
COMMENT => 'comment', |
30
|
|
|
|
|
|
|
DATE => 'releasedate', |
31
|
|
|
|
|
|
|
GENRE => 'genre', |
32
|
|
|
|
|
|
|
DISC => 'disc', |
33
|
|
|
|
|
|
|
LABEL => 'label', |
34
|
|
|
|
|
|
|
ASIN => 'asin', |
35
|
|
|
|
|
|
|
MUSICBRAINZ_ARTISTID => 'mb_artistid', |
36
|
|
|
|
|
|
|
MUSICBRAINZ_ALBUMID => 'mb_albumid', |
37
|
|
|
|
|
|
|
MUSICBRAINZ_TRACKID => 'mb_trackid', |
38
|
|
|
|
|
|
|
MUSICBRAINZ_SORTNAME => 'sortname', |
39
|
|
|
|
|
|
|
RELEASECOUNTRY => 'countrycode', |
40
|
|
|
|
|
|
|
MUSICIP_PUID => 'mip_puid', |
41
|
|
|
|
|
|
|
MUSICBRAINZ_ALBUMARTIST => 'albumartist' |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub set_values { |
45
|
0
|
|
|
0
|
1
|
0
|
return ( values %tagmap, 'picture'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub saved_values { |
49
|
0
|
|
|
0
|
1
|
0
|
return ( values %tagmap); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_tag { |
53
|
2
|
|
|
2
|
1
|
2393
|
my $self = shift; |
54
|
2
|
50
|
|
|
|
9
|
if ( $self->flac ) { |
55
|
2
|
|
|
|
|
5
|
while (my ($t, $v) = each %{$self->flac->tags}) { |
|
33
|
|
|
|
|
5262
|
|
56
|
31
|
100
|
66
|
|
|
298
|
if ((exists $tagmap{$t}) && (defined $v)) { |
57
|
27
|
|
|
|
|
40
|
my $method = $tagmap{$t}; |
58
|
27
|
|
|
|
|
239
|
$self->info->set_data($method,$v); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
2
|
|
|
|
|
17
|
$self->info->set_data('secs', $self->flac->{trackTotalLengthSeconds} ); |
62
|
2
|
|
|
|
|
235
|
$self->info->set_data('bitrate', int($self->flac->{bitRate} / 1000) ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#"MIME type" => The MIME Type of the picture encoding |
65
|
|
|
|
|
|
|
#"Picture Type" => What the picture is off. Usually set to 'Cover (front)' |
66
|
|
|
|
|
|
|
#"Description" => A short description of the picture |
67
|
|
|
|
|
|
|
#"_Data" => The binary data for the picture. |
68
|
2
|
50
|
33
|
|
|
71
|
if (( $self->flac->picture) && ( not $self->info->has_data('picture'))) { |
69
|
0
|
|
|
|
|
0
|
my $pic = $self->flac->picture; |
70
|
0
|
|
|
|
|
0
|
$self->info->set_data('picture', { |
71
|
|
|
|
|
|
|
"MIME type" => $pic->{mimeType}, |
72
|
|
|
|
|
|
|
"Picture Type" => $pic->{description}, |
73
|
|
|
|
|
|
|
"_Data" => $pic->{imageData}, |
74
|
|
|
|
|
|
|
}); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
2
|
|
|
|
|
96
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub set_tag { |
81
|
1
|
|
|
1
|
1
|
17790
|
my $self = shift; |
82
|
1
|
50
|
|
|
|
19
|
if ( $self->flac ) { |
83
|
1
|
|
|
|
|
9
|
while (my ($t, $v) = each %tagmap) { |
84
|
18
|
100
|
|
|
|
206
|
if ($self->info->has_data($v)) { |
85
|
15
|
|
|
|
|
423
|
$self->flac->tags->{$t} = $self->info->get_data($v); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
1
|
|
|
|
|
22
|
$self->flac->write(); |
89
|
|
|
|
|
|
|
} |
90
|
1
|
|
|
|
|
724
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub close { |
94
|
2
|
|
|
2
|
1
|
11031
|
my $self = shift; |
95
|
2
|
|
|
|
|
4
|
$self->{_Flac} = undef; |
96
|
2
|
|
|
|
|
62
|
delete $self->{_Flac}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub default_options { |
100
|
|
|
|
|
|
|
{ |
101
|
2
|
|
|
2
|
1
|
2170
|
wav_out_system => [ "flac", "-cd", "-c", "[FILENAME]" ], |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# vim: tabstop=4 |
108
|
|
|
|
|
|
|
__END__ |