added PKGBUILD for openssh-dnssec
[mirrors/Programs.git] / php / skripty / lyrics_bot.php
1 <?php
2 //Lyrics bot 0.1
3 //<-Harvie 2oo7
4 /*
5 This will search and show lyrics of specified song from lyricsplugin.com...
6 If you need WinAmp or WMP plug-in, look here: http://www.lyricsplugin.com/
7 */
8 ///FUNCTIONS////////////////////////////////////////////////////////////////
9 function get_lyrics($artist, $title) { //Finds and returns lyrics of song
10 $title = urlencode($title);
11 $artist = urlencode($artist);
12 $url = "http://www.lyricsplugin.com/plugin/?artist=$artist&title=$title";
13 //readfile($url); //Debug
14 if( !($fp = fopen($url, "r")) ) return("Error_1: Can't connect!");
15
16 $lyrics = "";
17 while( ($line = trim(fgets($fp))) != "<div id=\"lyrics\">" );
18 while( ($line = trim(fgets($fp))) != "</div>" ) {
19 $line = strip_tags($line);
20 //echo($line."\n");
21 $lyrics = $lyrics.$line."\n";
22 }
23
24 $lyrics = trim($lyrics);
25 if($lyrics == "") $lyrics = "Error_2: Lyrics not found!";
26 return($lyrics."\n");
27 }
28
29 function parse_music_info($filename) { //This returns array with music info (0 => Artist, 1 => Title) parsed from filename
30 $filename = explode("-", $filename);
31 $ret[0] = $filename[0];
32 $filename = split("(-|\\.)", $filename[1]);
33 $ret[1] = $filename[0];
34
35 $ret = str_replace("_", " ", $ret);
36 $ret[0] = trim($ret[0]);
37 $ret[1] = trim($ret[1]);
38 //print_r($filename); //Debug
39 //print_r($ret); //Debug
40 return $ret;
41 }
42
43 ///CODE/////////////////////////////////////////////////////////////////////
44 $song = parse_music_info("Jimi_Hendrix_-_Are_you_experienced.mp3");
45 echo("Lyrics for: ".$song[1]." by: ".$song[0]."\n\n");
46 echo get_lyrics($song[0] ,$song[1])."\n";
47 //echo get_lyrics("Jimi Hendrix" ,"Are you experienced");
48
49 ?>
This page took 0.296027 seconds and 4 git commands to generate.