blib/lib/Music/Tag/Coveralia.pm

filter: Statementstmt 76.3% 29 / 38 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 68.2% 43 / 63 CC 6 SCAR 16.9
CC
6
Cov
67%
get_tag
11.0
required_values
2.0
set_values
2.0
CRAP 5.4
↑ Summary
1 package Music::Tag::Coveralia;
2  
3 1 ▶use 5.014000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use parent qw/Music::Tag::Generic/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.001';
9  
10 1 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use WWW::Search;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶sub required_values { qw/album/ }
Subroutine required_values: not called CC=1 SCAR=6.9
Pod documented
14 0 ▶sub set_values { qw/picture/ }
Subroutine set_values: not called CC=1 SCAR=6.9
Pod documented
15  
16 1 my $ht = HTTP::Tiny->new(agent => "Music-Tag-Coveralia/$VERSION");
17  
18 2 ▶sub get_tag {
Subroutine get_tag: called CC=6 SCAR=24.0
Pod documented
19 2 my ($self) = @_;
20  
21 2 my $album = $self->info->album;
22 2 my $ws = WWW::Search->new('Coveralia::Albums');
23 2 $self->status(1, "Searching coveralia for the album $album");
24 2 $ws->native_query(WWW::Search::escape_query($album));
25 2 ▶ while (my $res = $ws->next_result) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $res = $ws->next_result) 1000 2 1002
26 1000 $self->status(1, 'Found album ' . $res->title . ' by ' . $res->artist);
27 1000 ▶ next if $self->info->has_data('artist') && $self->info->artist ne $res->artist;
Branch: 1 branch
BranchTrueFalseTotal
if $self->info->has_data("artist") and $self->info->artist ne $res->artist 1000 0 1000
Condition33%1/3
$self->info->has_data("artist") and $self->info->artist ne $res->artist
!ll&&!rl&&r
001000
MC/DC0%0/2
$self->info->has_data("artist") and $self->info->artist ne $res->artist
$self->info->has_data("artist") $self->info->artist ne $res->artist
Truth table33%1/3
A and B
A= $self->info->has_data("artist")B= $self->info->artist ne $res->artist
ABresult
0X0
100
111
28 0 $self->status(0, 'Selected album ' . $res->title . ' by ' . $res->artist);
29 0 ▶ if ($res->cover('frontal')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->cover("frontal")) 0 0 0
30 0 my $resp = $ht->get($res->cover('frontal'));
31 0 ▶ last unless $resp->{success};
Branch: 1 branch
BranchTrueFalseTotal
unless $resp->{"success"} 0 0 0
32 0 $self->info->picture({_Data => $resp->{content}});
33 0 $self->tagchange('picture');
34 }
35 last
36 0 }
37  
38 2 return $self->info
39 }
40  
41 1 1;
42 __END__
↑ Summary