cweiske's pick: skyriders
[stouyapi.git] / bin / import-game-data.php
index 467dac53d57ebf54270681856b72c82ab469e4e9..95549d33de179a57f5249e515f2feff89d8ace94 100755 (executable)
@@ -18,7 +18,8 @@ if (!is_file($foldersFile)) {
 
 $GLOBALS['packagelists']['cweiskepicks'] = [
     'de.eiswuxe.blookid2',
-    'com.cosmos.babyloniantwins'
+    'com.cosmos.babyloniantwins',
+    'com.inverseblue.skyriders',
 ];
 
 $wwwDir = __DIR__ . '/../www/';
@@ -124,6 +125,14 @@ writeJson(
     buildMakeCategory('Tutorials', filterByGenre($games, 'Tutorials'))
 );
 
+$searchLetters = 'abcdefghijklmnopqrstuvwxyz0123456789., ';
+foreach (str_split($searchLetters) as $letter) {
+    $letterGames = filterBySearchWord($games, $letter);
+    writeJson(
+        'api/v1/search-data/' . $letter . '.json',
+        buildSearch($letterGames)
+    );
+}
 
 
 function buildDiscover(array $games)
@@ -214,12 +223,7 @@ function buildDiscoverCategory($name, $games)
         filterBestRated($games, 10)
     );
 
-    usort(
-        $games,
-        function ($gameA, $gameB) {
-            return strcasecmp($gameA->title, $gameB->title);
-        }
-    );
+    $games = sortByTitle($games);
     $chunks = array_chunk($games, 4);
     foreach ($chunks as $chunkGames) {
         addDiscoverRow($data, '', $chunkGames);
@@ -236,12 +240,7 @@ function buildMakeCategory($name, $games)
         'tiles' => [],
     ];
 
-    usort(
-        $games,
-        function ($gameA, $gameB) {
-            return strcasecmp($gameA->title, $gameB->title);
-        }
-    );
+    $games = sortByTitle($games);
     addDiscoverRow($data, '', $games);
 
     return $data;
@@ -523,6 +522,23 @@ function buildPurchases($game)
     return $encryptedTwice;
 }
 
+function buildSearch($games)
+{
+    $games = sortByTitle($games);
+    $results = [];
+    foreach ($games as $game) {
+        $results[] = [
+            'title' => $game->title,
+            'url'   => 'ouya://launcher/details?app=' . $game->packageName,
+            'contentRating' => $game->contentRating,
+        ];
+    }
+    return [
+        'count'   => count($results),
+        'results' => $results,
+    ];
+}
+
 function dummyEncrypt($data)
 {
     return [
@@ -633,7 +649,7 @@ function buildDiscoverGameTile($game)
 
 function categoryPath($title)
 {
-    return str_replace(['/', '\\', ' ', '+'], '_', $title);
+    return str_replace(['/', '\\', ' ', '+', '?'], '_', $title);
 }
 
 function getAllAges($games)