Rewrite all URLs (images, videos, downloads)
[stouyapi.git] / bin / import-game-data.php
index 232b11fd3426b0712e074c5d171afb992d5ce849..d98dd3f3eb5388ba2554f07c94209ceff9f62337 100755 (executable)
@@ -431,7 +431,7 @@ function buildAppDownload($game, $release)
             'fileSize'      => $release->size,
             'version'       => $release->uuid,
             'contentRating' => $game->contentRating,
-            'downloadLink'  => rewriteUrl($release->url),
+            'downloadLink'  => $release->url,
         ]
     ];
 }
@@ -898,12 +898,21 @@ function addMissingGameProperties($game)
                 exit(20);
             }
         }
-        $qrUrlPath = '/gen-qr/' . $qrfileName;
+        $qrUrlPath = $GLOBALS['baseUrl'] . 'gen-qr/' . $qrfileName;
         $game->media[] = (object) [
             'type' => 'image',
             '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);
+    }
 }
 
 /**