4 * Take OUYA game data files and replace the broken download links
5 * with archive.org links
7 foreach (glob(__DIR__ . '/../games/*.json') as $gameFile) {
8 $gameData = json_decode(file_get_contents($gameFile));
11 foreach ($gameData->releases as $release) {
12 if (parse_url($release->url, PHP_URL_HOST) != 'devs-ouya-tv-prod.s3.amazonaws.com') {
13 echo " release url ok\n";
17 $releaseNameFile = str_replace(
22 $iaJsonFile = __DIR__ . '/../old-data/ia-data/'
23 . 'ouya_' . $gameData->packageName . '_' . $releaseNameFile . '.json';
24 if (!file_exists($iaJsonFile)) {
25 echo " IA file not found: $iaJsonFile\n";
28 $iaData = json_decode(file_get_contents($iaJsonFile));
31 foreach ($iaData->files as $iaFile) {
32 if ($iaFile->format == 'Android Package Archive') {
33 $iaSlug = basename($iaJsonFile, '.json');
34 $url = 'https://archive.org/download/' . $iaSlug . '/' . rawurlencode($iaFile->name);
38 echo " No apk found!\n";
47 echo " Saving game data\n";
48 file_put_contents($gameFile, json_encode($gameData, JSON_PRETTY_PRINT) . "\n");