From 19c4027e817d7bc3f864a56035dc88dfa30588c8 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Tue, 9 Jul 2024 16:50:16 +0200 Subject: [PATCH] json cache refactor for le monde --- epub.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/epub.php b/epub.php index ec98f0c..00f72ee 100644 --- a/epub.php +++ b/epub.php @@ -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)