1
0

Neu: Radio Gong Würzburg Bridge

This commit is contained in:
Akamaru
2025-12-01 13:19:05 +01:00
parent 9e3e73a704
commit 4a6ce141ac
2 changed files with 129 additions and 0 deletions

View File

@@ -175,6 +175,13 @@ Diese Sammlung enthält verschiedene Bridge-Implementierungen für RSS-Bridge, u
### [Punishing: Gray Raven News Bridge](https://bridge.ponywave.de/#bridge-PunishingGrayRavenNewsBridge) (Von Akamaru)
- **Beschreibung**: Zeigt die neuesten Nachrichten von Punishing: Gray Raven
### [Radio Gong Würzburg News Bridge](https://bridge.ponywave.de/#bridge-RadioGongWuerzburgBridge) (Von Akamaru)
- **Beschreibung**: Aktuelle Nachrichten von Radio Gong Würzburg
- **Hinweise**:
- Zeigt bis zu 20 aktuelle News-Artikel
- Enthält Titel, Datum, Kategorie (z.B. "Lokales") und Bilder
- Zeitstempel werden aus dem deutschen Datumsformat extrahiert
### [RSS Filter Bridge](https://bridge.ponywave.de/#bridge-RSSFilterBridge) (Von Akamaru)
- **Beschreibung**: Filtert und modifiziert Elemente aus beliebigen RSS/Atom-Feeds
- **Parameter**:

View File

@@ -0,0 +1,122 @@
<?php
declare(strict_types=1);
class RadioGongWuerzburgBridge extends BridgeAbstract
{
const NAME = 'Radio Gong Würzburg News';
const URI = 'https://www.radiogong.com/';
const DESCRIPTION = 'Aktuelle Nachrichten von Radio Gong Würzburg';
const MAINTAINER = 'Akamaru';
const CACHE_TIMEOUT = 3600; // 1 Stunde
public function getIcon()
{
return 'https://www.google.com/s2/favicons?domain=www.radiogong.com&sz=32';
}
public function collectData()
{
$url = 'https://www.radiogong.com/aktuelles/news';
$html = getSimpleHTMLDOM($url);
if (!$html) {
throw new \Exception('Konnte die Radio Gong Würzburg News-Seite nicht laden: ' . $url);
}
// Finde alle News-Artikel
$newsItems = $html->find('.teaser-list-item');
if (empty($newsItems)) {
throw new \Exception('Keine News-Artikel gefunden auf der Seite');
}
foreach ($newsItems as $newsItem) {
$item = [];
// Link und Titel extrahieren
$link = $newsItem->find('a', 0);
if (!$link) {
continue;
}
$item['uri'] = $link->href;
if (strpos($item['uri'], 'http') !== 0) {
$item['uri'] = self::URI . ltrim($item['uri'], '/');
}
// Titel aus h3
$titleElement = $newsItem->find('h3', 0);
if ($titleElement) {
$item['title'] = trim($titleElement->plaintext);
} else {
continue; // Überspringe Artikel ohne Titel
}
// Caption mit Datum und Kategorie extrahieren
// Format: "30.11.2025, 19:17 Uhr in Lokales"
$caption = $newsItem->find('.caption', 0);
if ($caption) {
$captionText = trim($caption->plaintext);
// Datum extrahieren (DD.MM.YYYY, HH:MM Uhr)
if (preg_match('/(\d{2})\.(\d{2})\.(\d{4}),\s+(\d{2}):(\d{2})\s+Uhr/', $captionText, $matches)) {
$day = $matches[1];
$month = $matches[2];
$year = $matches[3];
$hour = $matches[4];
$minute = $matches[5];
// Erstelle Timestamp
$item['timestamp'] = strtotime("$year-$month-$day $hour:$minute:00");
}
// Kategorie extrahieren (Text nach "in ")
if (preg_match('/in\s+(.+)$/i', $captionText, $categoryMatch)) {
$item['categories'] = [trim($categoryMatch[1])];
}
}
// Bild extrahieren
$image = $newsItem->find('img', 0);
if ($image) {
// Verwende data-srcset falls vorhanden, sonst src
$imageUrl = null;
if (isset($image->{'data-srcset'}) && !empty($image->{'data-srcset'})) {
// Nimm das erste Bild aus dem srcset
$srcset = $image->{'data-srcset'};
if (preg_match('/^(https?:\/\/[^\s]+)/', $srcset, $imageMatch)) {
$imageUrl = $imageMatch[1];
}
} elseif (isset($image->src) && !empty($image->src) && strpos($image->src, 'data:image') !== 0) {
// Nur normale URLs verwenden, keine base64-codierten Bilder
$imageUrl = $image->src;
}
if ($imageUrl) {
// Bereinige die URL (entferne .webp falls vorhanden und nimm die jpg-Variante)
$imageUrl = str_replace('.webp', '', $imageUrl);
$item['enclosures'] = [$imageUrl];
$item['content'] = '<img src="' . htmlspecialchars($imageUrl) . '" alt="' . htmlspecialchars($item['title']) . '">';
}
}
// Fallback für Timestamp
if (!isset($item['timestamp'])) {
$item['timestamp'] = time();
}
// Autor setzen
$item['author'] = 'Radio Gong Würzburg';
$this->items[] = $item;
// Limitiere auf 20 Artikel
if (count($this->items) >= 20) {
break;
}
}
}
}