json cache refactor for le monde
This commit is contained in:
parent
ce0f0ec37a
commit
19c4027e81
17
epub.php
17
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)
|
||||
|
|
Loading…
Reference in New Issue