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->epub_file = 'epub/lemonde.epub';
|
||||||
$epub->title = 'Le Monde ' . $date ;
|
$epub->title = 'Le Monde ' . $date ;
|
||||||
|
|
||||||
// cache json in case url expires
|
$publication = get_json($url);
|
||||||
$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);
|
|
||||||
$content = array_filter($publication->Content, function($item) { return $item->Category == 'Le Monde'; });
|
$content = array_filter($publication->Content, function($item) { return $item->Category == 'Le Monde'; });
|
||||||
usort($content, function ($a, $b) { return $a->PageNumber - $b->PageNumber; });
|
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;
|
$page = 0;
|
||||||
foreach ($content as $article)
|
foreach ($content as $article)
|
||||||
|
|
Loading…
Reference in New Issue