json cache refactor for le monde

This commit is contained in:
quenousimporte 2024-07-09 16:50:16 +02:00
parent ce0f0ec37a
commit 19c4027e81
1 changed files with 2 additions and 15 deletions

View File

@ -220,24 +220,11 @@
$epub->epub_file = 'epub/lemonde.epub';
$epub->title = 'Le Monde ' . $date ;
// cache json in case url expires
$tempjsonpath = 'temp/' . hash('md5', $url) . '.json';
$json = '';
if (file_exists($tempjsonpath))
{
$json = file_get_contents($tempjsonpath);
}
else
{
$json = file_get_contents($url);
file_put_contents($tempjsonpath, $json);
}
$publication = json_decode($json);
$publication = get_json($url);
$content = array_filter($publication->Content, function($item) { return $item->Category == 'Le Monde'; });
usort($content, function ($a, $b) { return $a->PageNumber - $b->PageNumber; });
$pageindex = json_decode(file_get_contents(str_replace('GetPublicationContentItems', 'GetPublicationPages', $url)));
$pageindex = get_json(str_replace('GetPublicationContentItems', 'GetPublicationPages', $url));
$page = 0;
foreach ($content as $article)