#!/usr/bin/perl use WWW::Mechanize; use HTML::Strip; use HTML::Entities; our $hs = HTML::Strip->new(); our $mech = WWW::Mechanize->new(); sub querylyrics { $mech->get("http://www.scroogle.org/cgi-bin/scraper.htm"); my $artist = urldecode(shift); my $title = urldecode(shift); $mech->field("Gw", "intitle:\"" . $title . "\" \"" . $artist . "\" lyrics", ); $mech->submit(); foreach ($mech->content() =~ m/\d*. /ig) { if ($_ =~ m/azlyrics\.com\/lyrics/i) { return azlyrics_scrape($_, $artist, $title) } elsif ($_ =~ m/lyrics007\.com/) { return l007_scrape($_, $artist, $title); } elsif ($_ =~ m/actionext\.com/) { return actionext_scrape($_, $artist, $title); } elsif ($_ =~ m/sing365\.com/) { return sing365_scrape($_, $artist, $title); } elsif ($_ =~ m/letssingit\.com/) { return letssingit_scrape($_, $artist, $title); } elsif ($_ =~ m/lyricwiki\.org/) { return lyricwiki_scrape($_, $artist, $title); } elsif ($_ =~ m/songmeanings\.net/) { return songmeanings_scrape($_, $artist, $title); } elsif ($_ =~ m/wearethelyrics\.com/) { return wearethelyrics_scrape($_, $artist, $title); } } return 0; } sub lyricwiki_scrape { my $loc = shift; $mech->get($loc); my $current = $mech->content(); my $out; if ($current =~ m/
(.*?)<\/div/s) { $out = $1; } else { print "Regex Failed for lyricwiki\n"; return 0; } $out =~ s/\n//sgi; $out =~ s//\n/sgi; my $doc = " " . encode_entities($hs->parse($out)) . ""; system("dcop", "amarok", "contextbrowser", "showLyrics", $doc); return 1; } sub letssingit_scrape { my $loc = shift; my $out; $mech->get($loc); my $current = $mech->content(); if ($current =~ m/
(.*)<\/PRE>/s) {
		$out = $1;
	} else {
		print "Regex Failed for letssingit\n";
		return 0;
	}
	my $doc = " " . encode_entities($hs->parse($out)) . "";
	system("dcop", "amarok", "contextbrowser", "showLyrics", $doc);
	return 1;
}


sub sing365_scrape {
	my $loc = shift;
	$mech->get($loc);
	my $current = $mech->content();
	my $out;
	if ($current =~ m/<\/font><\/a>

'\);(.*)
/s) { $out = $1; } else { print "Regex Failed for sing365\n"; return 0; } $out =~ s/\n//sgi; $out =~ s/
/\n/sgi; my $doc = " " . encode_entities($hs->parse($out)) . ""; system("dcop", "amarok", "contextbrowser", "showLyrics", $doc); return 1; } sub actionext_scrape { my $loc = shift; $mech->get($loc); my $current = $mech->content(); my $out; if ($current =~ m/