-
Notifications
You must be signed in to change notification settings - Fork 1
/
go.php
50 lines (40 loc) · 1.09 KB
/
go.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require __DIR__ . '/vendor/autoload.php';
$crewIndices = null;
$missionIndices = null;
try {
if (!empty($argv[1])) {
$verbosity = substr_count($argv[1], 'v');
$levels = [
Monolog\Logger::WARNING,
Monolog\Logger::NOTICE,
Monolog\Logger::INFO,
Monolog\Logger::DEBUG,
];
eidng8\Log\Log::setLevel($levels[$verbosity]);
}
eidng8\Log\Log::useStdio();
if (!is_dir(__DIR__ . '/www')) {
mkdir(__DIR__ . '/www', 0644);
}
$api_url = 'https://stt.wiki/w/api.php';
$api = new eidng8\Wiki\Api\Api(
new eidng8\Wiki\Api\Http($api_url),
__DIR__ . '/cache'
);
$wiki = new eidng8\Wiki(
$api->parse(),
$api->query(),
$api->expandTemplates()
);
$analyst = $wiki->analyse();
$export = $wiki->export();
$dir = __DIR__ . '/www';
if (!is_dir($dir)) {
mkdir($dir, 0644);
}
file_put_contents("$dir/data.json", json_encode($export, JSON_OPTIONS));
} catch (Exception $ex) {
eidng8\Log\Log::err($ex->getMessage());
exit(1);
}