30 lines
1.1 KiB
PHP
Executable File
30 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
if (!file_exists('public/posts_2023.json')) {
|
|
file_put_contents('public/posts_2023.json', download_posts('https://bookmeter.xyz/api/posts?edition=2023'));
|
|
}
|
|
if (!file_exists('public/posts_2024.json')) {
|
|
file_put_contents('public/posts_2024.json', download_posts('https://bookmeter.xyz/api/posts?edition=2024'));
|
|
}
|
|
if (!file_exists('public/posts_2025.json')) {
|
|
file_put_contents('public/posts_2025.json', download_posts('https://bookmeter.xyz/api/posts?edition=2025'));
|
|
}
|
|
file_put_contents('public/posts_2026.json', download_posts('https://bookmeter.xyz/api/posts?edition=2026'));
|
|
|
|
if (is_dir('dist')) {
|
|
copy('public/posts_2026.json', 'dist/posts_2026.json');
|
|
copy('public/posts_2025.json', 'dist/posts_2025.json');
|
|
copy('public/posts_2024.json', 'dist/posts_2024.json');
|
|
copy('public/posts_2023.json', 'dist/posts_2023.json');
|
|
}
|
|
function download_posts(string $url): false|string
|
|
{
|
|
$posts = file_get_contents($url);
|
|
$posts = json_decode($posts, true);
|
|
array_walk($posts, function (&$item) {
|
|
unset($item['image']);
|
|
});
|
|
|
|
return json_encode($posts);
|
|
}
|