* @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');
//default configuration values
$GLOBALS['packagelists'] = [];
+$GLOBALS['urlRewrites'] = [];
$cfgFile = __DIR__ . '/../config.php';
if (file_exists($cfgFile)) {
include $cfgFile;
'fileSize' => $release->size,
'version' => $release->uuid,
'contentRating' => $game->contentRating,
- 'downloadLink' => $release->url,
+ 'downloadLink' => rewriteUrl($release->url),
]
];
}
$mediaTiles[] = [
'type' => 'image',
'urls' => [
- 'thumbnail' => $medium->thumb,
+ 'thumbnail' => $medium->thumb ?? $medium->url,
'full' => $medium->url,
],
];
];
}
-function categoryPath($title)
-{
- return str_replace(['/', '\\', ' ', '+', '?'], '_', $title);
-}
-
function getAllAges($games)
{
$ages = [];
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;