Added lot of junk laying around on harvie.cz
[mirrors/Programs.git] / php / skripty / lyrics_bot.php
diff --git a/php/skripty/lyrics_bot.php b/php/skripty/lyrics_bot.php
new file mode 100644 (file)
index 0000000..72f8e08
--- /dev/null
@@ -0,0 +1,49 @@
+<?php\r
+//Lyrics bot 0.1\r
+//<-Harvie 2oo7\r
+/*\r
+This will search and show lyrics of specified song from lyricsplugin.com...\r
+If you need WinAmp or WMP plug-in, look here: http://www.lyricsplugin.com/\r
+*/\r
+///FUNCTIONS////////////////////////////////////////////////////////////////\r
+function get_lyrics($artist, $title) { //Finds and returns lyrics of song\r
+  $title = urlencode($title);\r
+  $artist = urlencode($artist);\r
+  $url = "http://www.lyricsplugin.com/plugin/?artist=$artist&title=$title";\r
+  //readfile($url); //Debug\r
+  if( !($fp = fopen($url, "r")) ) return("Error_1: Can't connect!");\r
+  \r
+  $lyrics = "";\r
+  while( ($line = trim(fgets($fp))) != "<div id=\"lyrics\">" );\r
+  while( ($line = trim(fgets($fp))) != "</div>" ) {\r
+    $line = strip_tags($line);\r
+    //echo($line."\n");\r
+    $lyrics = $lyrics.$line."\n";\r
+  }\r
+  \r
+  $lyrics = trim($lyrics);\r
+  if($lyrics == "") $lyrics = "Error_2: Lyrics not found!";\r
+  return($lyrics."\n");\r
+}\r
+\r
+function parse_music_info($filename) { //This returns array with music info (0 => Artist, 1 => Title) parsed from filename\r
+  $filename = explode("-", $filename);\r
+  $ret[0] = $filename[0];\r
+  $filename = split("(-|\\.)", $filename[1]);\r
+  $ret[1] = $filename[0];\r
+  \r
+  $ret = str_replace("_", " ", $ret);\r
+  $ret[0] = trim($ret[0]);\r
+  $ret[1] = trim($ret[1]);\r
+  //print_r($filename); //Debug\r
+  //print_r($ret); //Debug\r
+  return $ret;\r
+}\r
+\r
+///CODE/////////////////////////////////////////////////////////////////////\r
+$song = parse_music_info("Jimi_Hendrix_-_Are_you_experienced.mp3");\r
+echo("Lyrics for: ".$song[1]." by: ".$song[0]."\n\n");\r
+echo get_lyrics($song[0] ,$song[1])."\n";\r
+//echo get_lyrics("Jimi Hendrix" ,"Are you experienced");\r
+\r
+?>\r
This page took 0.132333 seconds and 4 git commands to generate.