Compare commits
No commits in common. "f5cc7bdb8605e8b171170083ffc942095bfa2561" and "62b7ae5a8e9db37ed5e882ee94431a02ce821644" have entirely different histories.
f5cc7bdb86
...
62b7ae5a8e
72
epub.php
72
epub.php
|
@ -21,7 +21,7 @@
|
|||
$nodeHTML = str_replace('</aside', '</i></b', $nodeHTML);
|
||||
$innerHTML .= $nodeHTML;
|
||||
}
|
||||
return '<div>' . strip_tags($innerHTML, '<p><b><h2><i><strong>') . '</div>';
|
||||
return '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
|
||||
}
|
||||
|
||||
function add_mp_article($url, $context, $epub)
|
||||
|
@ -397,71 +397,6 @@
|
|||
write_epub($epub);
|
||||
}
|
||||
|
||||
// Politis RSS
|
||||
if (isset($_POST['politis']) && $_POST['politis'])
|
||||
{
|
||||
$issuenb = '';
|
||||
if (isset($_POST['politisnb']))
|
||||
{
|
||||
$issuenb = $_POST['politisnb'];
|
||||
}
|
||||
$feedurl = 'https://www.politis.fr/flux-rss-politis-fr/';
|
||||
$opts = [
|
||||
'http' => [
|
||||
'method' => "GET",
|
||||
//'header' => "Accept-language: en\nCookie: MPSESSID=" . $mp_sessionid, // todo
|
||||
]
|
||||
];
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
// todo add cover!
|
||||
|
||||
$epub = new TPEpubCreator();
|
||||
$epub->temp_folder = 'temp/';
|
||||
$epub->epub_file = 'epub/politis' . $issuenb . '.epub';
|
||||
$epub->title = 'Politis ' . $issuenb . ' - RSS ' . $today;
|
||||
|
||||
// load feeds
|
||||
$feed = file_get_contents($feedurl);
|
||||
$xml = new SimpleXMLElement($feed);
|
||||
$items = $xml->xpath("/rss/channel/item");
|
||||
|
||||
// reverse to respect timing
|
||||
foreach (array_reverse($items) as $item)
|
||||
{
|
||||
$url = $item->link;
|
||||
$article = file_get_contents($url, false, $context);
|
||||
|
||||
if ($issuenb && !str_contains($article, ' dans l’hebdo N° ' . $issuenb))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadHTML($article);
|
||||
$finder = new DomXPath($doc);
|
||||
|
||||
$title = $finder->query('//h1')->item(0)->textContent;
|
||||
$author = $finder->query('//span[@class="nom"]')->item(0)->textContent;
|
||||
$date = $finder->query('//span[@class="date"]')->item(0)->textContent;
|
||||
$summary = $finder->query('//div[@class="extrait"]')->item(0)->textContent;
|
||||
|
||||
$result = '<h1>' . $title . '</h1>';
|
||||
$result .= '<p>' . $author . '</p>';
|
||||
$result .= '<p>' . $date . '</p>';
|
||||
$result .= '<p><b>' . $summary . '</b></p>';
|
||||
|
||||
$nodes = $finder->query('//div[@id="content"]');
|
||||
$node = $nodes->item(0);
|
||||
$nodehtml = get_clean_html($node);
|
||||
$result .= $nodehtml;
|
||||
$epub->AddPage($result, false, $title);
|
||||
|
||||
}
|
||||
|
||||
write_epub($epub);
|
||||
}
|
||||
|
||||
// Mediapart home page
|
||||
if (isset($_POST['mphome']) && $_POST['mphome'])
|
||||
{
|
||||
|
@ -656,11 +591,6 @@
|
|||
<input id="nyttoday" name="nyttoday" type="checkbox">
|
||||
<label for="nyttoday">From today's paper embedded script</label>
|
||||
|
||||
<h2>Politis</h2>
|
||||
<input id="politis" name="politis" type="checkbox">
|
||||
<label for="politis">From RSS.</label>
|
||||
<label for="politisnb">Optional issue number: </label><input id="politisnb" name="politisnb">
|
||||
|
||||
<h2>Admin</h2>
|
||||
<input id="emptycache" name="emptycache" type="checkbox" checked>
|
||||
<label for="emptycache">Empty cache</label>
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
<li><a href="https://www.cairn.info/revue-ecorev.htm">Eco Rev'</a></li>
|
||||
</ul>
|
||||
<li><a href="./epub">Fichiers epub</a></li>
|
||||
<li><a href="./epub.php">Génération epub</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue