From: Christian Weiske Date: Thu, 30 Apr 2020 14:17:26 +0000 (+0200) Subject: Allow .apk URL rewrites X-Git-Tag: v2.0.0~14 X-Git-Url: https://git.cweiske.de/stouyapi.git/commitdiff_plain/401f1919cfe020f5335a5c89a47c85694ca5188d Allow .apk URL rewrites So we can use our own server, even when the apk urls in the game data still point to archive.org --- diff --git a/bin/import-game-data.php b/bin/import-game-data.php index 9dc0510..283c06b 100755 --- a/bin/import-game-data.php +++ b/bin/import-game-data.php @@ -18,6 +18,7 @@ if (!is_file($foldersFile)) { //default configuration values $GLOBALS['packagelists'] = []; +$GLOBALS['urlRewrites'] = []; $cfgFile = __DIR__ . '/../config.php'; if (file_exists($cfgFile)) { include $cfgFile; @@ -373,7 +374,7 @@ function buildAppDownload($game, $release) 'fileSize' => $release->size, 'version' => $release->uuid, 'contentRating' => $game->contentRating, - 'downloadLink' => $release->url, + 'downloadLink' => rewriteUrl($release->url), ] ]; } @@ -884,6 +885,14 @@ function removeMakeGenres($genres) return $filtered; } +function rewriteUrl($url) +{ + foreach ($GLOBALS['urlRewrites'] as $pattern => $replacement) { + $url = preg_replace($pattern, $replacement, $url); + } + return $url; +} + function writeJson($path, $data) { global $wwwDir; diff --git a/config.php.dist b/config.php.dist index 11c34a2..030b1d6 100644 --- a/config.php.dist +++ b/config.php.dist @@ -3,6 +3,9 @@ * Optional configuration file for import-game-data.php * Copy it to config.php and adjust it. */ +$GLOBALS['urlRewrites'] = [ + '#^https://archive.org/download/#' => 'https://statics.ouya.world/ia/', +]; $GLOBALS['packagelists']["cweiske's picks"] = [ 'de.eiswuxe.blookid2', 'com.cosmos.babyloniantwins',