]> iEval git - music-tag-coveralia.git/blobdiff - lib/Music/Tag/Coveralia.pm
Clean up method calls
[music-tag-coveralia.git] / lib / Music / Tag / Coveralia.pm
index 6a2333503ee96b4c08b0e7c3fcff651e74786581..34ae9e13a071da5bf61d6ad9d543b5e5a76a2e03 100644 (file)
@@ -7,25 +7,29 @@ use parent qw/Music::Tag::Generic/;
 
 our $VERSION = '0.000_001';
 
-use LWP::Simple qw/get/;
+use HTTP::Tiny;
 use WWW::Search;
 
 sub required_values { qw/album/ }
 sub set_values { qw/picture/ }
 
+my $ht = HTTP::Tiny->new(agent => "Music-Tag-Coveralia/$VERSION");
+
 sub get_tag {
        my ($self) = @_;
 
-       my $album = $self->info->get_data('album');
+       my $album = $self->info->album;
        my $ws = WWW::Search->new('Coveralia::Albums');
        $self->status(1, "Searching coveralia for the album $album");
        $ws->native_query(WWW::Search::escape_query($album));
        while (my $res = $ws->next_result) {
                $self->status(1, 'Found album ' . $res->title . ' by ' . $res->artist);
-               next if $self->info->has_data('artist') && $self->info->get_data('artist') ne $res->artist;
+               next if $self->info->has_data('artist') && $self->info->artist ne $res->artist;
                $self->status(0, 'Selected album ' . $res->title . ' by ' . $res->artist);
                if ($res->cover('frontal')) {
-                       $self->info->set_data(picture => {_Data => get $res->cover('frontal')});
+                       my $resp = $ht->get($res->cover('frontal'));
+                       last unless $resp->{success};
+                       $self->info->picture({_Data => $resp->{content}});
                        $self->tagchange('picture');
                }
                last
This page took 0.02074 seconds and 4 git commands to generate.