X-Git-Url: https://git.cweiske.de/stouyapi.git/blobdiff_plain/5e4ffee3ec6ac775230341118cc6c4295350bfc8..7287030317ae7045440df94e557e25a4bc6f9890:/bin/build-html.php diff --git a/bin/build-html.php b/bin/build-html.php index 112a93d..c00f811 100755 --- a/bin/build-html.php +++ b/bin/build-html.php @@ -46,6 +46,47 @@ foreach (glob($discoverDir . '*.json') as $discoverFile) { ); } +file_put_contents( + $wwwDiscoverDir . 'allgames.htm', + renderAllGamesList(glob($gameDetailsDir . '*.json')) +); + + +function renderAllGamesList($detailsFiles) +{ + $games = []; + foreach ($detailsFiles as $gameDataFile) { + $json = json_decode(file_get_contents($gameDataFile)); + $games[] = (object) [ + 'packageName' => basename($gameDataFile, '.json'), + 'title' => $json->title, + 'genres' => $json->genres, + 'developer' => $json->developer->name, + 'developerUrl' => $json->stouyapi->{'developer-url'} ?? null, + 'suggestedAge' => $json->suggestedAge, + 'apkVersion' => $json->version->number, + 'apkTimestamp' => $json->version->publishedAt, + 'players' => $json->gamerNumbers, + 'detailUrl' => '../game/' . str_replace( + 'ouya://launcher/details?app=', + '', + basename($gameDataFile, '.json') + ) . '.htm', + ]; + } + $navLinks = [ + './' => 'back', + ]; + + $allGamesTemplate = __DIR__ . '/../data/templates/allgames.tpl.php'; + ob_start(); + include $allGamesTemplate; + $html = ob_get_contents(); + ob_end_clean(); + + return $html; +} + function renderDiscoverFile($discoverFile) { $json = json_decode(file_get_contents($discoverFile)); @@ -91,6 +132,7 @@ function renderDiscoverFile($discoverFile) $navLinks = []; if ($json->title == 'DISCOVER') { $navLinks['../'] = 'back'; + $navLinks['allgames.htm'] = 'all games'; $title = 'OUYA games list'; } else { $navLinks['./'] = 'discover'; @@ -118,7 +160,17 @@ function renderGameFile($gameDataFile) $appsDir . $json->version->uuid . '-download.json' ) ); + $apkDownloadUrl = $downloadJson->app->downloadLink; + /* + if (isset($json->premium) && $json->premium) { + $apkDownloadUrl = null; + } + */ + + $internetArchiveUrl = $json->stouyapi->{'internet-archive'} ?? null; + $developerUrl = $json->stouyapi->{'developer-url'} ?? null; + $pushUrl = $GLOBALS['pushToMyOuyaUrl'] . '?game=' . urlencode($json->apk->package);