39 lines
1.6 KiB
PHP
39 lines
1.6 KiB
PHP
<?php
|
|
|
|
$arr_camps = json_decode(file_get_contents('generated_camps.json'), false);
|
|
$gb_data = json_decode(file_get_contents('gb_data.json'), true);
|
|
|
|
foreach($arr_camps as &$obj_camp) {
|
|
if (!isset($gb_data[$obj_camp->url])) {
|
|
if (str_contains($obj_camp->url, '/mods/')) {
|
|
$gb_id = preg_replace('/.+\/(\d+)$/', '$1', $obj_camp->url);
|
|
$json = json_decode(shell_exec('curl -s "https://api.gamebanana.com/Core/Item/Data?itemtype=Mod&itemid=' . $gb_id . '&fields=name,Owner().name,userid"'));
|
|
if (isset($json[0])) {
|
|
$gb_data[$obj_camp->url]['name'] = $json[0];
|
|
$gb_data[$obj_camp->url]['author_name'] = $json[1];
|
|
$gb_data[$obj_camp->url]['author_id'] = $json[2];
|
|
} else {
|
|
$gb_data[$obj_camp->url]['name'] = 'GB_MOD_REMOVED_NAME';
|
|
$gb_data[$obj_camp->url]['author_name'] = 'GB_MOD_REMOVED_AUTHOR_NAME';
|
|
$gb_data[$obj_camp->url]['author_id'] = -1;
|
|
}
|
|
sleep(15);
|
|
} else {
|
|
$gb_data[$obj_camp->url]['name'] = 'NOTGB_MOD_NAME';
|
|
$gb_data[$obj_camp->url]['author_name'] = 'NOTGB_MOD_AUTHOR_NAME';
|
|
$gb_data[$obj_camp->url]['author_id'] = -2;
|
|
}
|
|
}
|
|
$obj_camp->name = $gb_data[$obj_camp->url]['name'];
|
|
$obj_camp->author_id = $gb_data[$obj_camp->url]['author_id'];
|
|
$obj_camp->author_name = $gb_data[$obj_camp->url]['author_name'];
|
|
echo $obj_camp->author_name . " - " . $obj_camp->name . "\n";
|
|
}
|
|
|
|
file_put_contents('gb_data.json',
|
|
json_encode($gb_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
|
|
);
|
|
|
|
file_put_contents('generated_camps.json',
|
|
json_encode($arr_camps, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
|
|
);
|