├── example.php
├── README.md
├── TODO.md
└── zippy_batch_dl.php
/example.php:
--------------------------------------------------------------------------------
1 | ';
8 | print_r($stuff);
9 | echo '';
10 | }
11 |
12 | $zippy_links = [
13 | "Rock Band ACDC" => [
14 | "http://www38.zippyshare.com/v/30819272/file.html",
15 | "http://www15.zippyshare.com/v/98285835/file.html",
16 | "http://www46.zippyshare.com/v/37059986/file.html",
17 | "http://www53.zippyshare.com/v/57652376/file.html",
18 | "http://www41.zippyshare.com/v/10556896/file.html",
19 | "http://www40.zippyshare.com/v/81927964/file.html"
20 | ],
21 | "Green Day Rock Band" => [
22 | "http://www72.zippyshare.com/v/27314844/file.html",
23 | "http://www6.zippyshare.com/v/5353353/file.html",
24 | "http://www49.zippyshare.com/v/49586179/file.html",
25 | "http://www25.zippyshare.com/v/75260868/file.html"
26 | ]
27 | ];
28 |
29 | //example usage
30 | $parent_folder = 'DL_new';
31 |
32 | $start_folder = 0;
33 | $end_folder = 'end';
34 |
35 | $start_link = 0;
36 | $end_link = 'end';
37 |
38 | print_r2($zippy_links);
39 |
40 | zippy_download_batch($zippy_links, $parent_folder, $start_folder, $end_folder, $start_link, $end_link);
41 |
42 | ?>
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **This repository is no longer maintained and contains some seriously low quality code!**
2 | ______________________________________________________
3 |
4 | # Zippyshare-batch-download-PHP-cURL
5 | A PHP (5.6.3) script that uses cURL to automatically download an array of Zippyshare links.
6 |
7 | [GitHub project](https://github.com/Quirinus/Zippyshare-batch-download-PHP-cURL)
8 | _____________________________________________________________________
9 |
10 | Run example.php to start downloading... use the zippy_batch_dl function (at the end of the file) and feed it arguments. log.php will be created in the download folder.
11 |
12 | _____________________________________________________________________
13 | Features:
14 | - Accepts arrays of zippyshare links, grouped by associative array that contains DL folder names.
15 | - Tries to automatically solve the anti-bot code to get the validation number, in a number of ways. (other scripts require manualy specifying it, thus having to stop downloading, which can happen several times for longer batches, and prevents afk downloading)
16 | - Names files by index, as they appear in the array, then by download link number, and then by file name.
17 | - While downloading, the file name is modified to be *.part.file_name.part - when finished it is renamed to remove both .part .
18 | - When starting a new session, always deletes partially downloaded files and starts downloading them again.
19 | - Can choose if you want to overwrite existing files.
20 | - Checks if files already exist by searching the folder for index number and download link number. Skips already existing complete downloads (unless overwrite is on).
21 | - Another check if file exists, after it fetches the file name from the zippyshare page. Skips already existing complete downloads (unless overwrite is on).
22 | - Can specify various timeout, wait and delay times.
23 | - Can specify from which folder/link to start, and where to end (can choose 'end' to go till the end).
24 | - Can specify download folder.
25 | - Has a pretty extensive log (not very well formatted).
26 | - Has a lot of error detection.
27 | - Example included: example.php just contains a bunch of working Zippyshare links/folders for testing/example purposes. zippy_batch_dl.php is the main file.
28 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | # Zippyshare-batch-download-PHP-cURL
2 | A PHP (5.6.3) script that uses cURL to automatically download an array of Zippyshare links.
3 |
4 | [GitHub project](https://github.com/Quirinus/Zippyshare-batch-download-PHP-cURL)
5 | _____________________________________________________________________
6 | To-Do:
7 | - Cosmetic/speed:
8 | - add datetimes to each log entry
9 | - clean up code... it's a mess atm.
10 | - make a nicer display of download links and their structure/number than it currently is.
11 | - format log to make it actually easy to read
12 | - check and note which PHP version and libraries this script uses (I'm running it on Windows 7 with: ApacheFriends XAMPP Version 5.6.3 which uses PHP 5.6.3 (VC11 X86 32bit thread safe) + PEAR, Apache 2.4.4, libraries: glob, curl...)
13 | - optimize code (eg. remove various preg matches if it can be done by quicker functions, maybe a faster approach than using the glob function, refactor some code...)
14 | - Features/functional:
15 | - add server index to the file name, between array index and url number
16 | - check file size first (read from site, CURLOPT_RANGE, CURLOPT_WRITEFUNCTION, CURLOPT_HEADERFUNCTION, or to get exact size, curl to get file size from header of the temp dl link - but that requires an aditional curl (if you do it, make it not request body, only header, and add other curl options to make it simpler)) If you read file size from from site, it's here: <font style="line-height:18px; font-size: 13px; font-weight: bold;">Size:</font><font style="line-height:18px; font-size: 13px;">29.52 MB</font><br /> : [Link 1](http://curl.haxx.se/libcurl/php/examples/callbacks.html), [Link 2](http://stackoverflow.com/questions/10991443/curl-get-remote-file-and-force-download-at-same-time)
17 | - re-download files if size doesn't match (give an optional argument for it, that overrides the overwrite argument)
18 | - make it constantly check a specified file for a 1 or 0 value. in case it's 0, stop running the script after finishing the current download.
19 | - add arbitrarily nested arrays of folder/links, along with support to specify download start/end folder/link indexes by having them nested like the folder/link array
20 | - increase the dl timeout according to the dl speed, only if script execution time isn't set to 0 (infinite)
21 | - - download resume: [Link 1](http://www.ankur.com/blog/106/php/resume-http-downloads-php-curl-fsockopen/), [Link 2](http://stackoverflow.com/questions/2032924/how-to-partially-download-a-remote-file-with-curl byteserving)
22 | - support for running two or more of these scripts in parallel
23 | - put variables from eval(algorithm_variables_code) in their own namespace?
--------------------------------------------------------------------------------
/zippy_batch_dl.php:
--------------------------------------------------------------------------------
1 | ', ':', '"', "/", "\\", '|', '?', '*')); //cannot be contained in file/folder names
16 | return trim(str_replace($bad, '', $path));
17 | }
18 |
19 | function left_to_right_slash($text)
20 | {
21 | return str_replace('\\','/',$text);
22 | }
23 |
24 | //formatting for the log file
25 | function red($text) //error
26 | {
27 | return "$text
\r\n";
28 | }
29 | function green($text) //success
30 | {
31 | return "$text
\r\n";
32 | }
33 | function strike($text) //skip
34 | {
35 | return "$text
\r\n";
36 | }
37 |
38 | //create just one level of folders
39 | function create_folders($paths)
40 | {
41 | if (is_array($paths))
42 | {
43 | foreach ($paths as $path)
44 | {
45 | if (!file_exists($path))
46 | mkdir($path, 0777, true);
47 | }
48 | }
49 | else
50 | {
51 | if (!file_exists($paths))
52 | mkdir($paths, 0777, true);
53 | }
54 | }
55 |
56 | //set time limit for the dl according to the file size and dl speed
57 | /*$filesize = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); //in bytes
58 | if ($filesize)
59 | set_time_limit(($filesize/(8*1024))/$dl_speed); //dl speed in kb/s*/
60 |
61 | //get zippyshare download page
62 | function _zippy_get_page($url, $response_time, $timeout, &$p_error)
63 | {
64 | if ($response_time > $timeout)
65 | $timeout = $response_time;
66 |
67 | $ch = curl_init();
68 | curl_setopt($ch, CURLOPT_URL, $url);
69 | curl_setopt($ch, CURLOPT_HEADER, 1);
70 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
71 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $response_time); //sec limited response time
72 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); //sec limited time
73 | $page = curl_exec($ch);
74 | if (curl_error($ch))
75 | $p_error = curl_error($ch);
76 | curl_close($ch);
77 | return $page;
78 | }
79 |
80 | //check if the zippyshare page is ok for processing
81 | function _page_has_errors($zippy_page, &$p_error)
82 | {
83 | //check for error while curling the page
84 | if (($p_error !== '') || ($zippy_page === false))
85 | $p_error = "Error fetching: $p_error";
86 |
87 | //check for empty page
88 | elseif (trim($zippy_page) == '')
89 | $p_error = 'Error: Page empty.';
90 |
91 | //check for title
92 | elseif (!(preg_match('/