Script to validate game files
[ouya-game-data.git] / bin / download-discover-images-ia.php
1 #!/usr/bin/env php
2 <?php
3 $files = glob(__DIR__ . '/../old-data/ia-data/*.json');
4 foreach ($files as $path) {
5     $file = basename($path);
6     $parts = explode('_', $file);
7     if (count($parts) != 3) {
8         continue;
9     }
10     if ($parts[0] != 'ouya') {
11         continue;
12     }
13     $package = $parts[1];
14     echo $package . "\n";
15
16     $data = json_decode(file_get_contents($path));
17     foreach ($data->files as $dfile) {
18         if ($dfile->name == '00ICON.png') {
19             $url = 'http://' . $data->d1
20                  . $data->dir . '/' . $dfile->name;
21             $dlfile = '/media/cweiske/videos/ouya-backup/game-images/' . strtolower($package) . '/discover';
22             if (file_exists($dlfile)) {
23                 echo " S\n";
24                 break;
25             }
26             echo ' ' . $url . "\n";
27             $cmd = 'curl -s ' . escapeshellarg($url)
28                  . ' -o ' . escapeshellarg($dlfile);
29             passthru($cmd);
30             break;
31         }
32     }
33     die();
34 }
35 ?>