"{}\n"
);
*/
-
+
writeJson(
'api/v1/apps/' . $game->packageName . '.json',
buildApps($game)
}
}
-writeJson('api/v1/discover.json', buildDiscover($games));
+writeJson('api/v1/discover-data/discover.json', buildDiscover($games));
writeJson('api/v1/discover-data/home.json', buildDiscoverHome($games));
$data, "cweiske's picks",
filterByPackageNames($games, $GLOBALS['packagelists']['cweiskepicks'])
);
-
+
$players = [
//1 => '1 player',
2 => '2 players',
usort(
$games,
function ($gameA, $gameB) {
- return strcmp($gameB->title, $gameA->title);
+ return strcmp($gameA->title, $gameB->title);
}
);
$chunks = array_chunk($games, 4);
'publicSize' => $latestRelease->publicSize,
'nativeSize' => $latestRelease->nativeSize,
- 'mainImageFullUrl' => $game->media->discover,
- 'videoUrl' => $game->media->video,
- 'filepickerScreenshots' => $game->media->screenshots,
+ 'mainImageFullUrl' => $game->discover,
+ 'videoUrl' => getFirstVideoUrl($game->media),
+ 'filepickerScreenshots' => getAllImageUrls($game->media),
'mobileAppIcon' => null,
'developer' => $game->developer->name,
$latestRelease = $game->latestRelease;
$mediaTiles = [];
- if ($game->media->discover) {
+ if ($game->discover) {
$mediaTiles[] = [
'type' => 'image',
'urls' => [
- 'thumbnail' => $game->media->discover,
- 'full' => $game->media->discover,
+ 'thumbnail' => $game->discover,
+ 'full' => $game->discover,
],
- 'fp_url' => $game->media->discover,
];
}
- if ($game->media->video) {
- $mediaTiles[] = [
- 'type' => 'video',
- 'url' => $game->media->video,
- ];
- }
- foreach ($game->media->screenshots as $screenshot) {
- $mediaTiles[] = [
- 'type' => 'image',
- 'urls' => [
- 'thumbnail' => $screenshot,
- 'full' => $screenshot,
- ],
- 'fp_url' => $screenshot,
- ];
+ foreach ($game->media as $medium) {
+ if ($medium->type == 'image') {
+ $mediaTiles[] = [
+ 'type' => 'image',
+ 'urls' => [
+ 'thumbnail' => $medium->thumb,
+ 'full' => $medium->url,
+ ],
+ ];
+ } else {
+ $mediaTiles[] = [
+ 'type' => 'video',
+ 'urls' => [
+ 'full' => $medium->url,
+ ],
+ ];
+ }
}
// http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-details
number_format($latestRelease->size / 1024 / 1024, 2, '.', '') . ' MiB',
],
- 'tileImage' => $game->media->discover,
+ 'tileImage' => $game->discover,
'mediaTiles' => $mediaTiles,
'mobileAppIcon' => null,
'heroImage' => [
'updated_at' => strtotime($latestRelease->date),
'updatedAt' => $latestRelease->date,
'title' => $game->title,
- 'image' => $game->media->discover,
+ 'image' => $game->discover,
'contentRating' => $game->contentRating,
'rating' => [
'count' => $game->rating->count,
error('No latest release for ' . $game->packageName);
}
- if (!isset($game->media->video)) {
- $game->media->video = null;
- }
- if (!isset($game->media->screenshots)) {
- $game->media->screenshots = [];
+ if (!isset($game->media)) {
+ $game->media = [];
}
+
if (!isset($game->developer->uuid)) {
$game->developer->uuid = null;
}
}
}
+function getFirstVideoUrl($media)
+{
+ foreach ($media as $medium) {
+ if ($medium->type == 'video') {
+ return $medium->url;
+ }
+ }
+ return null;
+}
+
+function getAllImageUrls($media)
+{
+ $imageUrls = [];
+ foreach ($media as $medium) {
+ if ($medium->type == 'image') {
+ $imageUrls[] = $medium->url;
+ }
+ }
+ return $imageUrls;
+}
+
function writeJson($path, $data)
{
global $wwwDir;
}
file_put_contents(
$fullPath,
- json_encode($data, JSON_PRETTY_PRINT) . "\n"
+ json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"
);
}