143 lines
5.8 KiB
PHP
143 lines
5.8 KiB
PHP
<?php
|
|
class EverSDBridge extends BridgeAbstract {
|
|
const NAME = 'EverSD News Bridge';
|
|
const URI = 'https://eversd.com/news';
|
|
const DESCRIPTION = 'EverSD News und Changelog.';
|
|
const MAINTAINER = 'Akamaru';
|
|
const CACHE_TIMEOUT = 3600; // 1 Stunde
|
|
|
|
public function getIcon() {
|
|
return 'https://eversd.com/____impro/1/onewebmedia/favico.png';
|
|
}
|
|
|
|
public function collectData() {
|
|
$html = getSimpleHTMLDOM(self::URI);
|
|
if (!$html) {
|
|
die('Die Seite konnte nicht geladen werden.');
|
|
}
|
|
|
|
$sections = $html->find('div[data-kind="SECTION"]');
|
|
if (empty($sections)) {
|
|
die('Keine Beiträge gefunden.');
|
|
}
|
|
|
|
foreach ($sections as $section) {
|
|
// Extrahiere Datum
|
|
$dateElement = $section->find('h3.textheading3', 0);
|
|
if (!$dateElement) {
|
|
continue; // Überspringe, wenn kein Datum vorhanden ist
|
|
}
|
|
$date = trim($dateElement->plaintext);
|
|
|
|
// Suche nach dem Textbereich mit dem Hauptinhalt
|
|
$textComponents = $section->find('div[data-specific-kind="TEXT"]');
|
|
if (empty($textComponents)) {
|
|
continue; // Überspringe, wenn kein Textbereich gefunden wurde
|
|
}
|
|
|
|
// Finde die Komponente mit dem Titel und Link
|
|
$titleElement = null;
|
|
$mainContent = null;
|
|
|
|
foreach ($textComponents as $textComponent) {
|
|
$linkElement = $textComponent->find('a.link4', 0);
|
|
if ($linkElement) {
|
|
$titleElement = $linkElement;
|
|
$mainContent = $textComponent;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!$titleElement) {
|
|
continue; // Überspringe, wenn kein Titel gefunden wurde
|
|
}
|
|
|
|
$title = trim($titleElement->plaintext);
|
|
$uri = urljoin(self::URI, $titleElement->href);
|
|
|
|
// Extrahiere Changelog-Inhalt aus dem Haupttextbereich
|
|
$content = '';
|
|
|
|
// Füge den Titel zum Content hinzu
|
|
$content .= '<h1>' . $title . '</h1>';
|
|
$content .= '<p>Datum: ' . $date . '</p>';
|
|
|
|
if ($mainContent) {
|
|
// Suche nach allen Überschriften, Listen und Absätzen im Haupttextbereich
|
|
$contentElements = $mainContent->find('h1, h2, h3, ul, p');
|
|
|
|
foreach ($contentElements as $element) {
|
|
// Überspringe den Titel, den wir bereits hinzugefügt haben
|
|
if ($element->tag == 'h1' && strpos($element->plaintext, $title) !== false) {
|
|
continue;
|
|
}
|
|
|
|
// Überspringe spezielle Absätze am Ende
|
|
if ($element->tag == 'p' &&
|
|
(strpos($element->plaintext, 'not only for EverSD') !== false ||
|
|
strpos($element->plaintext, 'Everyone can enjoy') !== false)) {
|
|
continue;
|
|
}
|
|
|
|
// Füge andere Elemente zum Inhalt hinzu
|
|
if ($element->tag == 'h2' || $element->tag == 'h3') {
|
|
$content .= '<' . $element->tag . '>' . trim($element->plaintext) . '</' . $element->tag . '>';
|
|
} elseif ($element->tag == 'ul') {
|
|
$content .= $element->outertext;
|
|
} elseif ($element->tag == 'p' && !empty(trim($element->plaintext))) {
|
|
$content .= '<p>' . trim($element->plaintext) . '</p>';
|
|
}
|
|
}
|
|
}
|
|
|
|
// Suche nach eingebetteten Videos
|
|
$videoComponents = $section->find('div[data-specific-kind="VIDEO"]');
|
|
if (!empty($videoComponents)) {
|
|
foreach ($videoComponents as $videoComponent) {
|
|
$iframe = $videoComponent->find('iframe', 0);
|
|
if ($iframe && isset($iframe->src)) {
|
|
$videoSrc = $iframe->src;
|
|
$content .= '<p><iframe width="480" height="270" src="' .
|
|
$videoSrc . '" frameborder="0" allowfullscreen></iframe></p>';
|
|
// In der Regel gibt es nur ein Video pro Beitrag
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Suche nach Bildern/Galleries
|
|
$galleryComponents = $section->find('div[data-specific-kind="GALLERY"]');
|
|
if (!empty($galleryComponents)) {
|
|
foreach ($galleryComponents as $galleryComponent) {
|
|
$images = $galleryComponent->find('img');
|
|
if (!empty($images)) {
|
|
$content .= '<div class="gallery">';
|
|
foreach ($images as $img) {
|
|
if (isset($img->src)) {
|
|
$content .= '<p><img src="' . $img->src . '" alt="' .
|
|
(isset($img->alt) ? $img->alt : 'EverSD Bild') . '"></p>';
|
|
}
|
|
}
|
|
$content .= '</div>';
|
|
}
|
|
}
|
|
}
|
|
|
|
// Erstelle ein neues Item
|
|
$item = [];
|
|
$item['title'] = $title;
|
|
$item['uri'] = $uri;
|
|
$item['timestamp'] = strtotime($date);
|
|
$item['content'] = $content;
|
|
$item['author'] = 'EverSD Team';
|
|
|
|
$this->items[] = $item;
|
|
}
|
|
|
|
// Sortiere die Beiträge nach Datum (neueste zuerst)
|
|
usort($this->items, function ($a, $b) {
|
|
return $b['timestamp'] - $a['timestamp'];
|
|
});
|
|
}
|
|
}
|