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