| 1 | <?php\r |
| 2 | //Jyxo seek\r |
| 3 | //<-Harvie (2oo7)\r |
| 4 | /*\r |
| 5 | Tento skript vam umozni vyhledavat a automaticky stahovat\r |
| 6 | multimedialni obsah parsovanim z vyhledavaciho enginu jyxo.cz.\r |
| 7 | */\r |
| 8 | \r |
| 9 | function url2filename($url) {\r |
| 10 | $url = explode("/", $url);\r |
| 11 | return $url[(sizeof($url)-1)];\r |
| 12 | }\r |
| 13 | //die(url2filename("http://johnys-pages.wbs.cz/03_-_Bob_Marley_-_No_woman_no_cry.mp3")); //Debug\r |
| 14 | \r |
| 15 | function jyxo_bot($q="",$d="mm",$ereg=".",$notereg="",$cnt=10000000000000,$page=1,$pmax=2,$o="nocls") {\r |
| 16 | \r |
| 17 | $i = 0;\r |
| 18 | $results = "";\r |
| 19 | $results[$i] = "";\r |
| 20 | //$q = str_replace(" ", "+", $q);\r |
| 21 | $q = urlencode($q);\r |
| 22 | for(;$page<=$pmax;$page++) {\r |
| 23 | $request = ("http://jyxo.cz/s?q=$q&d=$d&o=$o&cnt=$cnt&page=$page");\r |
| 24 | $fp = fopen($request, "r") or die(" !!! Cannot connect !!!");\r |
| 25 | while(!feof($fp)) {\r |
| 26 | $line = fgets($fp);\r |
| 27 | if(eregi("<div class='r'>", $line) && ereg(" class=ri", $line)) {\r |
| 28 | $line = explode("<!--m--><div class='r'><A HREF=\"", $line);\r |
| 29 | $line = $line[1];\r |
| 30 | $line = explode("\" class=ri", $line);\r |
| 31 | $line = trim($line[0]);\r |
| 32 | $line = urldecode($line);\r |
| 33 | \r |
| 34 | if(@eregi($ereg, $line) && !@eregi($notereg, $line) && !in_array($line, $results)) {\r |
| 35 | echo("$line\n"); //Output\r |
| 36 | //echo("$i:$line\n"); //Indexed Output\r |
| 37 | //echo("<a href=\"$line\">$line</a><br />\n"); //XHTML Output\r |
| 38 | $results[$i] = $line;\r |
| 39 | $i++;\r |
| 40 | }\r |
| 41 | \r |
| 42 | }\r |
| 43 | }\r |
| 44 | fclose($fp);\r |
| 45 | }\r |
| 46 | echo("\nTotal: $i\n"); //Sumary Output\r |
| 47 | return $results;\r |
| 48 | }\r |
| 49 | \r |
| 50 | //\r |
| 51 | function download_url_array($results, $download_dir) {\r |
| 52 | //$download_dir = $GLOBALS["download_dir"];\r |
| 53 | $fails = 0; $done = 0;\r |
| 54 | echo("\nDownloading to $download_dir ...\n");\r |
| 55 | if(!is_dir($download_dir)) {\r |
| 56 | echo("Creating directory: $download_dir\n\n");\r |
| 57 | mkdir($download_dir);\r |
| 58 | } else { echo("\n"); }\r |
| 59 | foreach($results as $id => $url) {\r |
| 60 | $file = url2filename($url);\r |
| 61 | echo("Downloading $file (#$id)... ");\r |
| 62 | $file = "$download_dir\\$file";\r |
| 63 | if(!is_file($file) && @copy($url, $file)) {\r |
| 64 | echo("Done.\n");\r |
| 65 | $done++;\r |
| 66 | } else {\r |
| 67 | if(is_file($file)) { echo("File already exists "); }\r |
| 68 | echo("Failed!\n");\r |
| 69 | $fails++;\r |
| 70 | }\r |
| 71 | }\r |
| 72 | $totaldls = ($fails+$done);\r |
| 73 | echo("\n$done/$totaldls files successfully downloaded to $download_dir ($fails failed)\n");\r |
| 74 | }\r |
| 75 | \r |
| 76 | ///CODE//////////////////////////////////////////////////////////////////////////////////////\r |
| 77 | $results = jyxo_bot("interpret titul","mm","(.mp3|.ogg)"); //Text2Search\r |
| 78 | //print_r($results); //Array Output\r |
| 79 | //var_dump($results); //Detail debug output\r |
| 80 | //download_url_array($results, "X:\\JyxoBot"); //Automatic Download\r |
| 81 | \r |
| 82 | ?>\r |