]>
iEval git - www-search-coveralia.git/blob - Coveralia/Result/Album.pm
1 package WWW
:: Search
:: Coveralia
:: Result
:: Album
;
6 use parent qw
/WWW::SearchResult/ ;
8 our $VERSION = '0.000_001' ;
10 use HTML
:: TreeBuilder
;
13 sub artist
{ shift -> _elem ( artist
=> @_ ) }
14 sub year
{ shift -> _elem ( year
=> @_ ) }
17 my ( $class , $obj , $url , $title , $artist , $year , $covers ) = @_ ;
18 my $self = $class -> SUPER :: new
;
20 $self ->{ covers
} = $covers if $covers ;
23 $self -> artist ( $artist );
31 my $tree = HTML
:: TreeBuilder
-> new_from_url ( $self -> url );
32 my $cover_list = $tree -> look_down ( class => 'lista_normal' );
33 my @covers = grep { ( $_ -> find ( 'img' )-> attr ( 'class' ) // '' ) ne 'sprites_enviax' } $cover_list -> find ( 'a' );
34 $self ->{ covers
} = { map { lc $_ -> as_text => $self ->{ obj
}-> absurl ( '' , $_ -> attr ( 'href' ))} @covers };
35 my @songs = $tree -> look_down ( id
=> 'pagina_disco_lista' )-> find ( 'tr' );
36 $self ->{ songs
} = [ map {
37 my ( $nr , $title , @extra ) = $_ -> find ( 'td' );
38 my %ret = ( id
=> $nr -> as_text , name
=> $title -> as_text );
40 next if ( $_ -> attr ( 'class' ) // '' ) eq 'letrano' ;
41 $ret { lyrics
} = $self ->{ obj
}-> absurl ( '' , $_ -> find ( 'a' )-> attr ( 'href' )) if $_ -> as_text =~ /letra/i ;
42 $ret { video
} = $self ->{ obj
}-> absurl ( '' , $_ -> find ( 'a' )-> attr ( 'href' )) if $_ -> as_text =~ /video/i ;
43 $ret { tab
} = $self ->{ obj
}-> absurl ( '' , $_ -> find ( 'a' )-> attr ( 'href' )) if $_ -> as_text =~ /acorde/i ;
51 $self -> parse_page unless $self ->{ covers
};
56 my ( $self , $cover ) = @_ ;
57 $self -> parse_page unless $self ->{ covers
};
58 $self ->{ covers
}{ $cover }
63 $self -> parse_page unless $self ->{ songs
};
74 WWW::Search::Coveralia::Result::Album - an album found by WWW::Search::Coveralia::Albums
78 my $result = $search->next_result;
79 say 'URL: ', $result->url;
80 say 'Name: ', $result->name;
81 my @albums = $result->albums;
82 # @albums is an array of WWW::Search::Coveralia::Result::Album objects
86 WWW::Search::Coveralia::Result::Album is the result of a WWW::Search::Coveralia::Albums search.
94 Returns a link to the album page on coveralia.
98 Returns the name of the album.
102 Returns the name of the artist of this album.
106 Returns the year when this album was released, or undef if the year is not known.
110 Returns a hash of cover art, with the kind of cover art as key and the link to the cover art page as value. This will change for the first stable version.
124 =item cd/cd1/cd2/dvd/dvd1/dvd2/...
128 =item interior1 / interior frontal
130 Interior frontal cover.
132 =item interior2 / interior trasera
138 =item B<cover>($type)
140 Convenience method. Returns a link to the cover art of a particular type. This will change for the first stable version.
144 Returns a list of songs in this album. Each song is a hashref with the following keys:
150 The track number of this song.
154 The name of this song.
158 Optional. A link to the lyrics of this song. Will likely change for the first stable version.
162 Optional. A link to the music video of this song. Will likely change for the first stable version.
166 Optional. A link to the tab of this song. Will likely change for the first stable version.
172 Downloads the covers page and extracts the albums. It is called automatically by other methods when necessary.
178 L<WWW::Search::Coveralia::Albums>
182 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
184 =head1 COPYRIGHT AND LICENSE
186 Copyright (C) 2014 by Marius Gavrilescu
188 This library is free software; you can redistribute it and/or modify
189 it under the same terms as Perl itself, either Perl version 5.18.1 or,
190 at your option, any later version of Perl 5 you may have available.
This page took 0.067314 seconds and 4 git commands to generate.