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