X-Git-Url: https://git.cweiske.de/stouyapi.git/blobdiff_plain/b739a2ab875baba8c97818db58c66bb7dfac3c26..3628cc39c1185b3deba69550ba64f8f4d9f563a3:/bin/import-game-data.php diff --git a/bin/import-game-data.php b/bin/import-game-data.php index 0073983..44f9b63 100755 --- a/bin/import-game-data.php +++ b/bin/import-game-data.php @@ -18,6 +18,8 @@ if (!is_file($foldersFile)) { } //default configuration values +$GLOBALS['baseUrl'] = 'http://ouya.cweiske.de/'; +$GLOBALS['categorySubtitles'] = []; $GLOBALS['packagelists'] = []; $GLOBALS['urlRewrites'] = []; $cfgFile = __DIR__ . '/../config.php'; @@ -175,8 +177,8 @@ function buildDiscover(array $games) filterLastAdded($games, 10) ); addDiscoverRow( - $data, 'Best rated', - filterBestRated($games, 10), + $data, 'Best rated games', + filterBestRatedGames($games, 10), true ); @@ -191,6 +193,7 @@ function buildDiscover(array $games) $data, 'Special', [ 'Best rated', + 'Best rated games', 'Most rated', 'Random', 'Last updated', @@ -200,6 +203,10 @@ function buildDiscover(array $games) 'api/v1/discover-data/' . categoryPath('Best rated') . '.json', buildSpecialCategory('Best rated', filterBestRated($games, 99)) ); + writeJson( + 'api/v1/discover-data/' . categoryPath('Best rated games') . '.json', + buildSpecialCategory('Best rated games', filterBestRatedGames($games, 99)) + ); writeJson( 'api/v1/discover-data/' . categoryPath('Most rated') . '.json', buildSpecialCategory('Most rated', filterMostDownloaded($games, 99)) @@ -284,15 +291,21 @@ function buildDiscoverCategory($name, $games) 'rows' => [], 'tiles' => [], ]; - addDiscoverRow( - $data, 'Last Updated', - filterLastUpdated($games, 10) - ); - addDiscoverRow( - $data, 'Best rated', - filterBestRated($games, 10), - true - ); + if (isset($GLOBALS['categorySubtitles'][$name])) { + $data['stouyapi']['subtitle'] = $GLOBALS['categorySubtitles'][$name]; + } + + if (count($games) >= 20) { + addDiscoverRow( + $data, 'Last Updated', + filterLastUpdated($games, 10) + ); + addDiscoverRow( + $data, 'Best rated', + filterBestRated($games, 10), + true + ); + } $games = sortByTitle($games); $chunks = array_chunk($games, 4); @@ -431,7 +444,7 @@ function buildAppDownload($game, $release) 'fileSize' => $release->size, 'version' => $release->uuid, 'contentRating' => $game->contentRating, - 'downloadLink' => rewriteUrl($release->url), + 'downloadLink' => $release->url, ] ]; } @@ -904,6 +917,15 @@ function addMissingGameProperties($game) 'url' => $qrUrlPath, ]; } + + //rewrite urls from Internet Archive to our servers + $game->discover = rewriteUrl($game->discover); + foreach ($game->media as $medium) { + $medium->url = rewriteUrl($medium->url); + } + foreach ($game->releases as $release) { + $release->url = rewriteUrl($release->url); + } } /**