line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Music::Tag::OGG; |
2
|
1
|
|
|
1
|
|
21504
|
use strict; use warnings; use utf8; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
38
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
53
|
|
|
1
|
|
|
|
|
10
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.4101'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Copyright © 2007,2008,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
|
|
1210
|
use Ogg::Vorbis::Header::PurePerl; |
|
1
|
|
|
|
|
3841
|
|
|
1
|
|
|
|
|
96
|
|
11
|
1
|
|
|
1
|
|
7
|
use base qw(Music::Tag::Generic); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1031
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %tagmap = ( |
14
|
|
|
|
|
|
|
TITLE => 'title', |
15
|
|
|
|
|
|
|
TRACKNUMBER => 'track', |
16
|
|
|
|
|
|
|
TRACKTOTAL => 'totaltracks', |
17
|
|
|
|
|
|
|
ARTIST => 'artist', |
18
|
|
|
|
|
|
|
ALBUM => 'album', |
19
|
|
|
|
|
|
|
COMMENT => 'comment', |
20
|
|
|
|
|
|
|
DATE => 'releasedate', |
21
|
|
|
|
|
|
|
GENRE => 'genre', |
22
|
|
|
|
|
|
|
DISC => 'disc', |
23
|
|
|
|
|
|
|
LABEL => 'label', |
24
|
|
|
|
|
|
|
ASIN => 'asin', |
25
|
|
|
|
|
|
|
MUSICBRAINZ_ARTISTID => 'mb_artistid', |
26
|
|
|
|
|
|
|
MUSICBRAINZ_ALBUMID => 'mb_albumid', |
27
|
|
|
|
|
|
|
MUSICBRAINZ_TRACKID => 'mb_trackid', |
28
|
|
|
|
|
|
|
MUSICBRAINZ_SORTNAME => 'sortname', |
29
|
|
|
|
|
|
|
RELEASECOUNTRY => 'countrycode', |
30
|
|
|
|
|
|
|
MUSICIP_PUID => 'mip_puid', |
31
|
|
|
|
|
|
|
MUSICBRAINZ_ALBUMARTIST => 'albumartist' |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub default_options { |
35
|
1
|
|
|
1
|
1
|
74
|
{ vorbiscomment => "vorbiscomment" } |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub set_values { |
39
|
0
|
|
|
0
|
1
|
0
|
return ( values %tagmap, 'picture'); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub saved_values { |
43
|
0
|
|
|
0
|
1
|
0
|
return ( values %tagmap, 'picture'); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub ogg { |
47
|
10
|
|
|
10
|
1
|
55
|
my $self = shift; |
48
|
10
|
100
|
66
|
|
|
157
|
unless ((exists $self->{_OGG}) && (ref $self->{_OGG})) { |
49
|
1
|
50
|
|
|
|
5
|
if ($self->info->get_data('filename')) { |
50
|
1
|
|
|
|
|
185
|
$self->{_OGG} = Ogg::Vorbis::Header::PurePerl->new($self->info->get_data('filename')); |
51
|
|
|
|
|
|
|
#$self->{_OGG}->load(); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
0
|
|
|
|
|
0
|
return undef; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
10
|
|
|
|
|
11805
|
return $self->{_OGG}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_tag { |
61
|
1
|
|
|
1
|
1
|
1239
|
my $self = shift; |
62
|
1
|
50
|
|
|
|
3
|
if ( $self->ogg ) { |
63
|
1
|
|
|
|
|
7
|
foreach ($self->ogg->comment_tags) { |
64
|
6
|
|
|
|
|
2557
|
my $comment = uc($_); |
65
|
6
|
100
|
|
|
|
19
|
if (exists $tagmap{$comment}) { |
66
|
5
|
|
|
|
|
8
|
my $method = $tagmap{$comment}; |
67
|
5
|
|
|
|
|
15
|
$self->info->set_data($method, $self->ogg->comment($comment)); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
1
|
|
|
|
|
23
|
$self->status("Unknown comment: $comment"); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
57
|
$self->info->set_data('secs',$self->ogg->info->{"length"}); |
74
|
1
|
|
|
|
|
52
|
$self->info->set_data('bitrate',$self->ogg->info->{"bitrate_nominal"}); |
75
|
1
|
|
|
|
|
46
|
$self->info->set_data('frequency',$self->ogg->info->{"rate"}); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
0
|
|
|
|
|
0
|
print STDERR "No ogg object created\n"; |
79
|
|
|
|
|
|
|
} |
80
|
1
|
|
|
|
|
49
|
return $self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub set_tag { |
85
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
86
|
0
|
0
|
|
|
|
0
|
unless (open(COMMENT, "|-", $self->options->{vorbiscomment} ." -w ". "\"". $self->info->get_data('filename') . "\"")) { |
87
|
0
|
|
|
|
|
0
|
$self->status("Failed to open ", $self->options->{vorbiscomment}, ". Not writing tag.\n"); |
88
|
0
|
|
|
|
|
0
|
return undef; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
0
|
while (my ($t, $m) = each %tagmap) { |
91
|
0
|
0
|
|
|
|
0
|
if (defined $self->info->get_data($m)) { |
92
|
0
|
|
|
|
|
0
|
print COMMENT $t, "=", $self->info->get_data($m), "\n"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
0
|
close (COMMENT); |
96
|
0
|
|
|
|
|
0
|
return $self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub close { |
100
|
1
|
|
|
1
|
1
|
4199
|
my $self = shift; |
101
|
1
|
|
|
|
|
26
|
$self->{_OGG} = undef; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |