1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-01-16 13:50:01 +01:00

Fix MondeDiplo empty date (#4407)

This commit is contained in:
Simon Alberny 2025-01-15 20:50:56 +01:00 committed by GitHub
parent eadea242a7
commit 5214581386
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,14 +19,28 @@ class MondeDiploBridge extends BridgeAbstract
foreach ($html->find('div.unarticle') as $article) {
$element = $article->parent();
$title = $element->find('h3', 0)->plaintext;
$datesAuteurs = $element->find('div.dates_auteurs', 0)->plaintext;
$titleElement = $element->find('h3', 0);
if (!$titleElement) {
continue;
}
$title = $titleElement->plaintext;
$datesAuteursElement = $element->find('div.dates_auteurs', 0);
$datesAuteurs = is_null($datesAuteursElement) ? '' : $element->find('div.dates_auteurs', 0)->plaintext;
$item = [];
$item['uri'] = urljoin(self::URI, $element->href);
$item['title'] = $this->cleanText($title) . ' - ' . $this->cleanText($datesAuteurs);
$item['title'] = $this->getItemTitle($title, $datesAuteurs);
$item['content'] = $this->cleanText(str_replace([$title, $datesAuteurs], '', $element->plaintext));
$this->items[] = $item;
}
}
private function getItemTitle($title, $datesAuteurs)
{
$itemTitle = $this->cleanText($title);
if (strlen($datesAuteurs) > 0) {
$itemTitle .= ' - ' . $this->cleanText($datesAuteurs);
}
return $itemTitle;
}
}