private function collect_images($url, $dir) { $continue = true; $domain = 'http://rule34.xxx/'; $base = 'http://rule34.xxx/index.php'; do { echo $url . "\n"; $p = new Page($url); $p->go_line('class="thumb"'); do { if ($p->curr_line()->contain('href="')) { $href = $p->curr_line()->cut_between('href="', '"')->to_s(); $href = htmlspecialchars_decode($href); echo "{$domain}{$href}\n"; $p2 = new Page($domain . $href); $p2->go_line('Original image'); $src = $p2->curr_line()->cut_between('href="http:', '"')->to_s(); $src = 'http:' . $src; $outpath = $dir . basename($src); download_it($src, $outpath, "--header=\"Accept: image/*\""); // echo '<pre>'.htmlspecialchars($p2->curr_line()).'</pre>'; } } while (!$p->next_line()->contain('<center>')); $p->reset_line(); $p->go_line('id="paginator"'); if ($p->curr_line()->contain('alt="next"')) { $m = $p->curr_line()->regex_match('/href="([^"]+)" alt="next"/'); $url = $base . html_entity_decode($m[1]); } else { $continue = false; } } while ($continue); }
private function download_images() { for ($n = count($this->images) - 1; $n >= 0; $n--) { $img_url = $this->images[$n]; $output = $this->dir . basename($img_url); echo "Downloading {$img_url}...\n"; download_it($img_url, $output); } }
private function download_video($streams, $choice, $dir, $filename) { if (!isset($streams[$choice])) { echo "INVALID CHOICE!"; return; } $stream = $streams[$choice]; $new_filename = "{$dir}/{$filename}.{$stream->ext}"; download_it($stream->url, $new_filename); }
private function download_images($json) { foreach ($json->data as $post) { $output = $this->output_path($post); // try hires $image_url = isset($post->images[0]) ? $post->images[0]->source : $post->source; if (!is_file($output)) { echo "Downloading {$image_url}\n"; download_it($image_url, $output); } } }
private function download_images($images, $dir) { $i = 1; $dir = substr($dir, 0, 120); foreach ($images as $page_url) { $ext = '.jpg'; $filename = Text::create($i)->pad(3)->to_s() . $ext; $outpath = $dir . $filename; if (!is_file($outpath)) { $retry = false; do { $image_src = $this->get_image_src($page_url); // $ext = Text::create($image_src)->cut_rafter('.')->to_s(); download_it($image_src, $outpath); $retry = filesize($outpath) === 0; } while ($retry); } $i++; } }
private function download_chapters($chapters) { $prefix = 'Birth_of_Levi'; $dir = '/home/khandar-gdp/tmp/birth of levi/'; foreach ($chapters as $infix => $url) { echo "Opening {$url}...\n"; $p = new Page($url); $p->go_line('pages[1]='); $i = 1; do { $line = $p->curr_line(); $img = $line->cut_between('="', '"'); $suffix = Text::create($i++)->pad(3)->to_s(); $ext = $img->cut_rafter('.'); $filename = "{$dir}{$prefix}-{$infix}-{$suffix}.{$ext}"; if (!is_file($filename)) { download_it($img->to_s(), $filename); } } while ($p->next_line()->contain('pages[')); } }
private function download_episodes($dir, $episodes) { $dir = rtrim($dir, '/') . '/'; foreach ($episodes as $url => $text) { $episode_dir = $dir . $text . '/'; if (!is_dir($episode_dir)) { mkdir($episode_dir); $h = $this->open($url); $i = 1; $thumbnails = $h->find('#modal-chapter-thumbnail', 0); foreach ($thumbnails->find('.img-thumbnail') as $img) { $src = $img->src; $src = str_replace('https:', 'http:', $src); $src = preg_replace('/\\/150x200\\//', '/600x0/', $src); $src = preg_replace('/\\/160x90\\//', '/1200x0/', $src); $filename = Text::create($i++)->pad(3)->to_s(); $outpath = $episode_dir . $filename . '.jpg'; download_it($src, $outpath); } } } }
file_put_contents('disneycomics.phase2', ob_get_clean()); break; case 'phase3': require 'disneycomics.phase2'; foreach ($a as $name => $comics) { foreach ($comics as $title => $pages) { echo "{$name}\\{$title}\n"; flush(); exec("mkdir \"{$name}\\{$title}\\\""); foreach ($pages as $file => $img) { $file = html_entity_decode($file); // quickfix $img = html_entity_decode($img); $output_file = "{$name}\\{$title}\\{$file}"; //echo "<a href='$img'>$name/$title/$file</a><br/>\n";flush(); download_it($img, $output_file); /* exec("wget -t 0 --retry-connrefused -O \"$name\\$title\\$file\" $img"); */ } } } break; case 'phase3b': // phase 3 pake concurrent download curl require 'disneycomics.phase2'; foreach ($a as $name => $comics) { // cUrl init $n = 0; $size = 2; // mau berapa concurrent download at a time
private function save_to($url, $file) { download_it($url, $file, "--header=\"Accept: image/*\""); }
$s['value'] = date('Y-m-d H:i:s', strtotime($date)); $s['key'] = $report_condition_KEY; $DIA->save('report_condition', $s); # #update export table with new request $e['Status'] = 'Active'; $e['key'] = $export_KEY; $DIA->save('export', $e); } $last = get_export($export_KEY); $rec = get_export($rec_export_KEY); if ($_GET['action'] == 'donation') { download_it($report_condition_KEY, $export_KEY, $last['Last_Run']); } if ($_GET['action'] == 'rec') { download_it($rec_report_condition_KEY, $rec_export_KEY, $rec['Last_Run']); } ?> <h2>Donation Report</h2> You last downloaded <a href="<?php echo SALSA_HQ_LIST; ?> lists/<?php echo $last['Last_Filename']; ?> ">this file</a> with <?php echo $last['Last_Linecount']; ?>
private function download_if_not_exist($img, $dir, $id) { if ($img->pos('//') === 0) { $src = 'https:' . $img->to_s(); } else { $src = $img->to_s(); } $filename = $img->cut_rafter('/')->cut_before('?'); $outpath = $dir . Text::create($id)->pad(3)->to_s() . '-' . $filename->to_s(); $hash = $filename->cut_rbefore('.')->to_s(); if (!in_array($hash, $this->existing_hashes($dir)) && !is_file($outpath)) { sleep(3); download_it($src, $outpath, "--header=\"User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2\""); } }