File Coverage

blib/lib/Music/Tag/Coveralia.pm
Criterion Covered Total %
statement 32 34 94.1
branch 3 4 75.0
condition 2 3 66.6
subroutine 7 9 77.7
pod 3 3 100.0
total 47 53 88.6


line stmt bran cond sub pod time code
1             package Music::Tag::Coveralia;
2              
3 1     1   386723 use 5.014000;
  1         3  
  1         27  
4 1     1   3 use strict;
  1         1  
  1         28  
5 1     1   4 use warnings;
  1         5  
  1         29  
6 1     1   4 use parent qw/Music::Tag::Generic/;
  1         1  
  1         10  
7              
8             our $VERSION = '0.000_001';
9              
10 1     1   509 use LWP::Simple qw/get/;
  1         35427  
  1         7  
11 1     1   1033 use WWW::Search;
  1         63986  
  1         359  
12              
13 0     0 1 0 sub required_values { qw/album/ }
14 0     0 1 0 sub set_values { qw/picture/ }
15              
16             sub get_tag {
17 2     2 1 5662 my ($self) = @_;
18              
19 2         8 my $album = $self->info->get_data('album');
20 2         57 my $ws = WWW::Search->new('Coveralia::Albums');
21 2         6534 $self->status(1, "Searching coveralia for the album $album");
22 2         84 $ws->native_query(WWW::Search::escape_query($album));
23 2         1108 while (my $res = $ws->next_result) {
24 2         20478671 $self->status(1, 'Found album ' . $res->title . ' by ' . $res->artist);
25 2 100 66     110 next if $self->info->has_data('artist') && $self->info->get_data('artist') ne $res->artist;
26 1         71 $self->status(0, 'Selected album ' . $res->title . ' by ' . $res->artist);
27 1 50       27 if ($res->cover('frontal')) {
28 1         238496 $self->info->set_data(picture => {_Data => get $res->cover('frontal')});
29 1         72728 $self->tagchange('picture');
30             }
31             last
32 1         136 }
33              
34 2         115 return $self->info
35             }
36              
37             1;
38             __END__