]>
iEval git - www-search-coveralia.git/blob - Artist.pm
15bce6fb610936e87f20e607dd7c3c468a60dd9d
1 package WWW
::Search
::Coveralia
::Result
::Artist
;
6 use parent qw
/WWW::SearchResult/;
8 our $VERSION = '0.001';
10 use HTML
::TreeBuilder
;
11 use List
::MoreUtils qw
/pairwise/;
13 use WWW
::Search
::Coveralia
::Result
::Album
;
16 my ($class, $obj, $id, $name) = @_;
17 my $self = $class->SUPER::new
;
22 $self->add_url("http//www.coveralia.com/autores/$id.php");
28 unless ($self->{albums
}) {
30 my $tree = HTML
::TreeBuilder
->new_from_url("http://www.coveralia.com/caratulas-de/$id.php");
31 my @albums = $tree->look_down(class => 'artista');
32 my @cover_lists = $tree->look_down(class => qr/\blista_normal\b/);
34 $self->{albums
} = [pairwise
{
35 my ($album, $cover_list) = ($a, $b);
36 my ($year) = $album->find('span') && ($album->find('span')->as_text =~ /^\((\d+)/);
37 $year = $year || undef;
38 $album = $album->find('a');
39 my $title = $album->as_text;
40 my $url = $self->{obj
}->absurl('', $album->attr('href'));
41 my %covers = map {lc $_->as_text => $self->{obj
}->absurl('', $_->attr('href'))} $cover_list->find('a');
42 WWW
::Search
::Coveralia
::Result
::Album
->new($self->{obj
}, $url, $title, $self->title, $year, \
%covers);
43 } @albums, @cover_lists];
56 WWW::Search::Coveralia::Result::Artist - an artist found by WWW::Search::Coveralia::Artists
60 my $result = $search->next_result;
61 say 'URL: ', $result->url;
62 say 'Name: ', $result->name;
63 my @albums = $result->albums;
64 # @albums is an array of WWW::Search::Coveralia::Result::Album objects
68 WWW::Search::Coveralia::Result::Artist is the result of a WWW::Search::Coveralia::Artists search.
76 Returns a link to the artist page on coveralia.
80 Returns the name of the artist.
84 Returns a list of albums (L<WWW::Search::Coveralia::Result::Album> objects) belonging to this artist. Calls B<parse_page> if not called already.
88 Downloads the covers page and extracts the albums. It is called automatically by B<albums> when necessary.
94 L<WWW::Search::Coveralia::Artists>
98 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
100 =head1 COPYRIGHT AND LICENSE
102 Copyright (C) 2014 by Marius Gavrilescu
104 This library is free software; you can redistribute it and/or modify
105 it under the same terms as Perl itself, either Perl version 5.18.1 or,
106 at your option, any later version of Perl 5 you may have available.
This page took 0.06131 seconds and 3 git commands to generate.