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)