blib/lib/Music/Tag/LyricsFetcher.pm

filter: Statementstmt 73.5% 25 / 34 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 62.1% 41 / 66 CC 7 SCAR 21.4
CC
7
Cov
63%
get_tag
15.9
set_values
2.0
BEGIN
1.0
CRAP 8.5
↑ Summary
1 package Music::Tag::LyricsFetcher;
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 © 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 Lyrics::Fetcher;
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 1 ▶sub default_options {{
Subroutine default_options: called CC=1 SCAR=0.0
Pod documented
14 1 'lyricsoverwrite' => 0,
15 'lyricsfetchers' => undef,
16 }}
17  
18 1 ▶sub get_tag {
Subroutine get_tag: called CC=7 SCAR=27.7
Pod documented
19 1 my $self = shift;
20 1 ▶ unless ( $self->info->has_data('artist') && $self->info->has_data('title') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->info->has_data("artist") and $self->info->has_data("title")) 0 1 1
Condition33%1/3
$self->info->has_data("artist") and $self->info->has_data("title")
!ll&&!rl&&r
001
MC/DC0%0/2
$self->info->has_data("artist") and $self->info->has_data("title")
$self->info->has_data("artist") $self->info->has_data("title")
Truth table33%1/3
A and B
A= $self->info->has_data("artist")B= $self->info->has_data("title")
ABresult
0X0
100
111
21 0 $self->status("Lyrics lookup requires ARTIST and TITLE already set!");
22 0 return;
23 }
24 1 ▶ if ( $self->info->lyrics && not $self->options->{lyricsoverwrite} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->info->lyrics and not $self->options->{'lyricsoverwrite'}) { } 0 1 1
Condition33%1/3
$self->info->lyrics and not $self->options->{"lyricsoverwrite"}
!ll&&!rl&&r
100
MC/DC0%0/2
$self->info->lyrics and not $self->options->{"lyricsoverwrite"}
$self->info->lyrics not $self->options->{"lyricsoverwrite"}
Truth table33%1/3
A and not(B)
A= $self->info->lyricsB= not $self->options->{"lyricsoverwrite"}
ABresult
0X0
100
111
25 0 $self->status("Lyrics already in tag");
26 }
27 else {
28 1 my $lyrics = Lyrics::Fetcher->fetch($self->info->get_data('artist'), $self->info->get_data('title'), $self->options->{lyricsfetchers});
29 1 ▶ if (($Lyrics::Fetcher::Error eq "OK") && ($lyrics)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Lyrics::Fetcher::Error eq 'OK' and $lyrics) { } 0 1 1
Condition33%1/3
$Lyrics::Fetcher::Error eq "OK" and $lyrics
!ll&&!rl&&r
100
MC/DC0%0/2
$Lyrics::Fetcher::Error eq "OK" and $lyrics
$Lyrics::Fetcher::Error eq "OK" $lyrics
Truth table33%1/3
A and B
A= $Lyrics::Fetcher::Error eq "OK"B= $lyrics
ABresult
0X0
100
111
30 0 my $lyricsl = $lyrics;
31 0 $lyricsl =~ s/[\r\n]+/ \/ /g;
32 0 $self->tagchange( "Lyrics", substr( "$lyricsl", 0, 50 ) . "..." );
33 0 $self->info->set_data('lyrics',$lyrics);
34 0 $self->info->changed(1);
35 }
36 else {
37 1 $self->status("Lyrics not found: ", $Lyrics::Fetcher::Error);
38 }
39 }
40 1 return $self;
41 }
42  
43 0 ▶sub set_values {
Subroutine set_values: not called CC=1 SCAR=6.9
Pod documented
44 0 return qw(lyrics);
45 }
46  
47 2 1;
48  
49 __END__
↑ Summary