-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsecond_chanse_grabber.php
More file actions
64 lines (44 loc) · 1.42 KB
/
Copy pathsecond_chanse_grabber.php
File metadata and controls
64 lines (44 loc) · 1.42 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include 'helpers.php';
$files = load_db_form_file();
$files_sorted = $files;
function cmp($a, $b)
{
return $a->{'timestamp'} > $b->{'timestamp'};
}
rsort($files_sorted);
print ('<p>count($files_sorted) is ' . count($files_sorted) . '</p>');
$downloaded_files = [];
$dir = 'saved/';
for ($i = 0; $i < count($files_sorted); $i++) {
$file = $files_sorted[$i];
if ($file->{'size'} == 0) {
$filename = $file->{'path'};
$t = $file->{'unified_number'};
$url = 'https://static.ctvnews.ca/cky/webcam/600_wpg_live_eye.jpg?ver=a' . $t;
file_put_contents($filename, fopen($url, 'r'));
$file_with_meta_data = get_file_meta_data($dir, $t . '.jpg', true);
print '<p>' . $filename . ' saved.</p>';
// var_dump($file);
// var_dump($files_sorted[$i]);
// var_dump($file_with_meta_data);
$files_sorted[$i] = $file_with_meta_data;
array_push($downloaded_files, $file_with_meta_data);
usleep(200);
}
if (count($downloaded_files) == 1000) {
break;
}
}
export_db_to_file($files_sorted);
print ('<p>count($files_sorted) is ' . count($files_sorted) . '</p>');
print ('<p>count($downloaded_files) is ' . count($downloaded_files) . '</p>');
print ('<br />');
/*foreach ($downloaded_files as $file) {
print (render_file($file, false));
}*/
$files_grouped_by_hash = group_by_key($downloaded_files, 'hash');
foreach ($files_grouped_by_hash as $group) {
print ('<p>'.$group[0]->{'hash'}.' - '.count($group).'</p>');
}
?>