| 1 | package Music::Tag::OGG; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; use warnings; use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | 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 | 2 | ▶ | use Ogg::Vorbis::Header::PurePerl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use base qw(Music::Tag::Generic); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | 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 | 1 | ▶ | sub default_options { | ||||||||||||||||||||||||||
|
Subroutine
default_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 1 | { vorbiscomment => "vorbiscomment" } | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub set_values { | ||||||||||||||||||||||||||
|
Subroutine
set_values: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 0 | return ( values %tagmap, 'picture'); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub saved_values { | ||||||||||||||||||||||||||
|
Subroutine
saved_values: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | return ( values %tagmap, 'picture'); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 10 | ▶ | sub ogg { | ||||||||||||||||||||||||||
|
Subroutine
ogg: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 48 | 10 | ▶ | unless ((exists $self->{_OGG}) && (ref $self->{_OGG})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"_OGG"} and ref $self->{"_OGG"}
MC/DC50%1/2
exists $self->{"_OGG"} and ref $self->{"_OGG"}
exists $self->{"_OGG"}
ref $self->{"_OGG"}
Truth table66%2/3
A and B
A= exists $self->{"_OGG"}B= ref $self->{"_OGG"}
| |||||||||||||||||||||||||||||
| 49 | 1 | ▶ | if ($self->info->get_data('filename')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 1 | $self->{_OGG} = Ogg::Vorbis::Header::PurePerl->new($self->info->get_data('filename')); | |||||||||||||||||||||||||||
| 51 | #$self->{_OGG}->load(); | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||
| 54 | 0 | return undef; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 10 | return $self->{_OGG}; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | ▶ | sub get_tag { | ||||||||||||||||||||||||||
|
Subroutine
get_tag: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 1 | ▶ | if ( $self->ogg ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 1 | foreach ($self->ogg->comment_tags) { | |||||||||||||||||||||||||||
| 64 | 6 | my $comment = uc($_); | |||||||||||||||||||||||||||
| 65 | 6 | ▶ | if (exists $tagmap{$comment}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 5 | my $method = $tagmap{$comment}; | |||||||||||||||||||||||||||
| 67 | 5 | $self->info->set_data($method, $self->ogg->comment($comment)); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | else { | ||||||||||||||||||||||||||||
| 70 | 1 | $self->status("Unknown comment: $comment"); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 1 | $self->info->set_data('secs',$self->ogg->info->{"length"}); | |||||||||||||||||||||||||||
| 74 | 1 | $self->info->set_data('bitrate',$self->ogg->info->{"bitrate_nominal"}); | |||||||||||||||||||||||||||
| 75 | 1 | $self->info->set_data('frequency',$self->ogg->info->{"rate"}); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||
| 78 | 0 | print STDERR "No ogg object created\n"; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 1 | return $self; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub set_tag { | ||||||||||||||||||||||||||
|
Subroutine
set_tag: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 86 | 0 | ▶ | unless (open(COMMENT, "|-", $self->options->{vorbiscomment} ." -w ". "\"". $self->info->get_data('filename') . "\"")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | $self->status("Failed to open ", $self->options->{vorbiscomment}, ". Not writing tag.\n"); | |||||||||||||||||||||||||||
| 88 | 0 | return undef; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | while (my ($t, $m) = each %tagmap) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (defined $self->info->get_data($m)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | print COMMENT $t, "=", $self->info->get_data($m), "\n"; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 0 | close (COMMENT); | |||||||||||||||||||||||||||
| 96 | 0 | return $self; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | ▶ | sub close { | ||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 100 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 1 | $self->{_OGG} = undef; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 2 | 1; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | __END__ | ||||||||||||||||||||||||||||