Link game pages to internet archive
authorChristian Weiske <cweiske@cweiske.de>
Wed, 27 May 2020 20:14:35 +0000 (22:14 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 27 May 2020 20:14:35 +0000 (22:14 +0200)
bin/build-html.php
bin/import-game-data.php
data/templates/game.tpl.php

index 3f6fa4b..18e25e5 100755 (executable)
@@ -159,7 +159,16 @@ function renderGameFile($gameDataFile)
             $appsDir . $json->version->uuid . '-download.json'
         )
     );
             $appsDir . $json->version->uuid . '-download.json'
         )
     );
+
     $apkDownloadUrl = $downloadJson->app->downloadLink;
     $apkDownloadUrl = $downloadJson->app->downloadLink;
+    /*
+    if (isset($json->premium) && $json->premium) {
+        $apkDownloadUrl = null;
+    }
+    */
+
+    $internetArchiveUrl = $json->stouyapi->{'internet-archive'} ?? null;
+
     $pushUrl = $GLOBALS['pushToMyOuyaUrl']
         . '?game=' . urlencode($json->apk->package);
 
     $pushUrl = $GLOBALS['pushToMyOuyaUrl']
         . '?game=' . urlencode($json->apk->package);
 
index 11ed6b3..cfd1630 100755 (executable)
@@ -449,6 +449,13 @@ function buildDetails($game)
         $product = buildProduct($gamePromoted);
     }
 
         $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',
     // http://cweiske.de/ouya-store-api-docs.htm#get-https-devs-ouya-tv-api-v1-details
     return [
         'type'             => 'Game',
@@ -507,6 +514,10 @@ function buildDetails($game)
 
         'promotedProduct' => $product,
         'buttons'         => $buttons,
 
         'promotedProduct' => $product,
         'buttons'         => $buttons,
+
+        'stouyapi' => [
+            'internet-archive' => $iaUrl,
+        ]
     ];
 }
 
     ];
 }
 
index 60f9326..ce9c561 100644 (file)
@@ -68,6 +68,7 @@
 
   <section class="buttons">
    <h2>Links</h2>
 
   <section class="buttons">
    <h2>Links</h2>
+   <?php if ($apkDownloadUrl): ?>
    <div>
     <a href="<?= $apkDownloadUrl ?>">Download .apk</a>
     <p>
    <div>
     <a href="<?= $apkDownloadUrl ?>">Download .apk</a>
     <p>
      <?= gmdate('Y-m-d', $json->version->publishedAt) ?>
     </p>
    </div>
      <?= gmdate('Y-m-d', $json->version->publishedAt) ?>
     </p>
    </div>
+   <?php endif ?>
+   <?php if ($internetArchiveUrl): ?>
+   <div>
+    <a href="<?= $internetArchiveUrl ?>">Internet Archive page</a>
+   </div>
+   <?php endif ?>
    <div>
     <form method="post" action="<?= htmlspecialchars($pushUrl) ?>" id="push" onsubmit="pushToMyOuya();return false;">
      <button name="push" type="submit" class="push-to-my-ouya">
    <div>
     <form method="post" action="<?= htmlspecialchars($pushUrl) ?>" id="push" onsubmit="pushToMyOuya();return false;">
      <button name="push" type="submit" class="push-to-my-ouya">