| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lyrics::Fetcher::AstraWeb; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# AstraWeb - lyrics.astraweb.com implementation |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Copyright (C) 2003 Sir Reflog |
|
6
|
|
|
|
|
|
|
# All rights reserved. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Maintainership of Lyrics::Fetcher transferred in Feb 07 to BIGPRESH |
|
9
|
|
|
|
|
|
|
# (David Precious ) |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# $Id: AstraWeb.pm 333 2008-04-24 18:53:53Z davidp $ |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1084
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
52
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
34
|
|
|
15
|
1
|
|
|
1
|
|
1429
|
use WWW::Mechanize; |
|
|
1
|
|
|
|
|
259764
|
|
|
|
1
|
|
|
|
|
48
|
|
|
16
|
1
|
|
|
1
|
|
13
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
400
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '0.33'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub fetch { |
|
21
|
0
|
|
|
0
|
1
|
|
my($self,$artist, $title) = @_; |
|
22
|
0
|
|
|
|
|
|
my $agent = WWW::Mechanize->new(); |
|
23
|
0
|
|
|
|
|
|
my($sartist) = join ("+", split(/ /, $artist)); |
|
24
|
0
|
|
|
|
|
|
my($stitle) = join ("+", split(/ /, $title)); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# quote regexp meta-characters to avoid breakage: |
|
27
|
0
|
|
|
|
|
|
$title = quotemeta $title; |
|
28
|
0
|
|
|
|
|
|
$artist = quotemeta $artist; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$agent->get("http://search.lyrics.astraweb.com/?word=$sartist+$stitle"); |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if(grep { $_->text() =~ /$title/ }@{$agent->links}) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$agent->follow_link(text_regex => qr((?-xism:$title))); |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if(grep { $_->text() =~ /Printable/ }@{$agent->links}) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$agent->follow_link(text_regex => qr((?-xism:Printable))); |
|
37
|
|
|
|
|
|
|
} else { |
|
38
|
0
|
|
|
|
|
|
$Lyrics::Fetcher::Error = 'Bad page format'; |
|
39
|
0
|
|
|
|
|
|
return; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} else { |
|
42
|
0
|
|
|
|
|
|
$Lyrics::Fetcher::Error = 'Cannot find such title'; |
|
43
|
0
|
|
|
|
|
|
return; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
0
|
|
|
|
return $agent->content =~ /(.*)<\/blockquote>/ && $1; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Lyrics::Fetcher::AstraWeb - Get song lyrics from lyrics.astraweb.com |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Lyrics::Fetcher; |
|
58
|
|
|
|
|
|
|
print Lyrics::Fetcher->fetch("","","AstraWeb"); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# or, if you want to use this module directly without Lyrics::Fetcher's |
|
61
|
|
|
|
|
|
|
# involvement (be aware that using Lyrics::Fetcher is the recommended way): |
|
62
|
|
|
|
|
|
|
use Lyrics::Fetcher::AstraWeb; |
|
63
|
|
|
|
|
|
|
print Lyrics::Fetcher::AstraWeb->fetch('', ''); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This module tries to get song lyrics from lyrics.astraweb.com. It's designed |
|
69
|
|
|
|
|
|
|
to be called by Lyrics::Fetcher, and this is the recommended usage, but it can |
|
70
|
|
|
|
|
|
|
be used directly if you'd prefer. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 INTERFACE |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item fetch($artist, $title) |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Attempts to fetch lyrics. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=back |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 BUGS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Probably. If you find any bugs, please let me know. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright (C) 2007 by David Precious |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
93
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
David Precious Edavidp@preshweb.co.ukE |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 LEGAL DISCLAIMER |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Legal disclaimer: I have no connection with the owners of astraweb.com. |
|
104
|
|
|
|
|
|
|
Lyrics fetched by this script may be copyrighted by the authors, it's up to |
|
105
|
|
|
|
|
|
|
you to determine whether this is the case, and if so, whether you are entitled |
|
106
|
|
|
|
|
|
|
to request/use those lyrics. You will almost certainly not be allowed to use |
|
107
|
|
|
|
|
|
|
the lyrics obtained for any commercial purposes. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |