Remove "large" from scripts
[ouya-game-data.git] / bin / print-image-urls.php
1 #!/usr/bin/env php
2 <?php
3 /**
4  * - s3.amazonaws.com are still ok
5  * - d3e4aumcqn8cw3.cloudfront.net URLs are down
6  *   - 8522 mirrored by cweiske
7  *   - 2039 missing
8  *     - 583 in internet archive
9  * - filepicker-URLs have the same IDs as cloudfront, and are down :/
10  */
11 $files = glob(__DIR__ . '/../games/*.json');
12 foreach ($files as $file) {
13     $data = json_decode(file_get_contents($file));
14     $package = $data->packageName;
15     collectFile($package, $data->media->discover, 'discover');
16     if (count($data->media->screenshots ?? [])) {
17         $pos = 0;
18         foreach ($data->media->screenshots as $url) {
19             collectFile($package, $url, 'screenshot-' . ++$pos);
20         }
21     }
22     if (count($data->media->details ?? [])) {
23         $pos = 0;
24         foreach ($data->media->details as $detail) {
25             if ($detail->type == 'image') {
26                 collectFile($package, $detail->url, 'detail-' . ++$pos);
27                 collectFile($package, $detail->thumb, 'detail-' . $pos . '-thumb');
28             }
29         }
30     }
31     //die();
32 }
33
34 function collectFile($package, $url, $type)
35 {
36     preg_match('#https://www.filepicker.io/api/file/([^/]+)/convert\?w=720#', $url, $matches);
37     if (isset($matches[1])) {
38         $url = 'https://d3e4aumcqn8cw3.cloudfront.net/api/file/' . $matches[1];
39     }
40     echo $url . "\n";
41     return;
42     echo $package
43         . "," . $type
44         . "," . $url
45         . "\n";
46 }
47 ?>