forked from K-S-V/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEugeniaVoda.php
43 lines (39 loc) · 1.08 KB
/
EugeniaVoda.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
function ShowHeader($header)
{
$len = strlen($header);
$width = (int) ((80 - $len) / 2) + $len;
$format = "\n%" . $width . "s\n\n";
printf($format, $header);
}
ShowHeader("KSV EugeniaVoda Downloader");
$format = "%-8s : ";
if ($argc <= 2)
{
printf($format, "URL");
$url = trim(fgets(STDIN));
printf($format, "Filename");
$filename = trim(fgets(STDIN));
}
else
{
$url = $argv[1];
$filename = $argv[2];
}
echo "Retrieving data . . .\n";
$json = file_get_contents($url . "/offsets.json");
$chunks = json_decode($json);
if (!$chunks)
die("Failed to decode json");
$fh = fopen($filename, 'wb');
fwrite($fh, pack("H*", "464C5601050000000900000000"));
$total_chunks = count($chunks);
for ($i = 0; $i < $total_chunks; $i++)
{
echo "Downloading " . ($i + 1) . "/$total_chunks chunks\r";
$data = file_get_contents($url . "/$chunks[$i].flvtags");
fwrite($fh, $data);
}
fclose($fh);
echo "\nFinished\n";
?>