Link game pages to internet archive
[stouyapi.git] / bin / import-game-data.php
index 14996c4635a71e5ebb27f6544722f1db404d3c68..cfd16308e5eba6f93d3fbc634c39600d5d525271 100755 (executable)
@@ -7,6 +7,7 @@
  * @author Christian Weiske <cweiske@cweiske.de>
  */
 ini_set('xdebug.halt_level', E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE);
+require_once __DIR__ . '/functions.php';
 require_once __DIR__ . '/filters.php';
 if (!isset($argv[1])) {
     error('Pass the path to a "folders" file with game data json files folder names');
@@ -448,6 +449,13 @@ function buildDetails($game)
         $product = buildProduct($gamePromoted);
     }
 
+    $iaUrl = null;
+    if (isset($game->latestRelease->url)
+        && substr($game->latestRelease->url, 0, 29) == 'https://archive.org/download/'
+    ) {
+        $iaUrl = dirname($game->latestRelease->url) . '/';
+    }
+
     // http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-details
     return [
         'type'             => 'Game',
@@ -506,6 +514,10 @@ function buildDetails($game)
 
         'promotedProduct' => $product,
         'buttons'         => $buttons,
+
+        'stouyapi' => [
+            'internet-archive' => $iaUrl,
+        ]
     ];
 }
 
@@ -698,11 +710,6 @@ function buildDiscoverGameTile($game)
     ];
 }
 
-function categoryPath($title)
-{
-    return str_replace(['/', '\\', ' ', '+', '?'], '_', $title);
-}
-
 function getAllAges($games)
 {
     $ages = [];