From 238f109644e6644417765e9d1afaa94469208cde Mon Sep 17 00:00:00 2001 From: Akamaru Date: Mon, 24 Nov 2025 00:00:00 +0100 Subject: [PATCH] Verbessere Beschreibungen in Feeds & setze Limits --- ARDMediathekSeriesBridge.php | 51 +++++++++++++++++++++---------- AnimationDigitalNetworkBridge.php | 51 +++---------------------------- DMAXBridge.php | 26 ++++++++++++++-- RTLPlusBridge.php | 17 ++++++++--- ToggoBridge.php | 21 +++++++++++-- 5 files changed, 93 insertions(+), 73 deletions(-) diff --git a/ARDMediathekSeriesBridge.php b/ARDMediathekSeriesBridge.php index 9901e31..06af1fc 100644 --- a/ARDMediathekSeriesBridge.php +++ b/ARDMediathekSeriesBridge.php @@ -106,7 +106,7 @@ class ARDMediathekSeriesBridge extends BridgeAbstract $item['author'] = $teaser['publicationService']['name']; } - // Content: Bild + Beschreibung + Verfügbarkeit + // Content: Bild + Beschreibung $content = ''; // Vorschaubild @@ -118,21 +118,12 @@ class ARDMediathekSeriesBridge extends BridgeAbstract $content .= '' . htmlspecialchars($imageAlt) . '
'; } - // Dauer - if (isset($teaser['duration'])) { - $duration = gmdate('H:i:s', $teaser['duration']); - $content .= '

Dauer: ' . $duration . '

'; - } - - // Verfügbar bis - if (isset($teaser['availableTo'])) { - $availableTo = date('d.m.Y H:i', strtotime($teaser['availableTo'])); - $content .= '

Verfügbar bis: ' . $availableTo . ' Uhr

'; - } - - // Untertitel verfügbar - if (isset($teaser['subtitled']) && $teaser['subtitled']) { - $content .= '

Untertitel verfügbar

'; + // Episoden-Beschreibung per Detail-API abrufen + if (!empty($episodeId)) { + $synopsis = $this->getEpisodeSynopsis($episodeId); + if (!empty($synopsis)) { + $content .= '

' . htmlspecialchars($synopsis) . '

'; + } } $item['content'] = $content; @@ -171,4 +162,32 @@ class ARDMediathekSeriesBridge extends BridgeAbstract return null; } + + /** + * Holt die Beschreibung einer Episode von der Detail-API + */ + private function getEpisodeSynopsis(string $episodeId): ?string + { + $apiUrl = 'https://api.ardmediathek.de/page-gateway/pages/ard/item/' . urlencode($episodeId); + + try { + $jsonData = getContents($apiUrl); + $data = json_decode($jsonData, true); + + if (!$data || !isset($data['widgets']) || !is_array($data['widgets'])) { + return null; + } + + // Synopsis ist im ersten Widget (player_ondemand) + foreach ($data['widgets'] as $widget) { + if (!empty($widget['synopsis'])) { + return $widget['synopsis']; + } + } + } catch (Exception $e) { + // Bei Fehlern einfach keine Beschreibung zurückgeben + } + + return null; + } } diff --git a/AnimationDigitalNetworkBridge.php b/AnimationDigitalNetworkBridge.php index 75aeb9f..1d810c7 100644 --- a/AnimationDigitalNetworkBridge.php +++ b/AnimationDigitalNetworkBridge.php @@ -120,60 +120,17 @@ class AnimationDigitalNetworkBridge extends BridgeAbstract { $item['author'] = $episodeDetails['show']['title']; } - // Content aufbauen + // Content: Bild + Beschreibung $content = ''; // Bild if (!empty($video['image'])) { - $content .= '' . htmlspecialchars($item['title']) . '

'; + $content .= '' . htmlspecialchars($item['title']) . '
'; } - // Summary/Beschreibung + // Beschreibung if (isset($episodeDetails['summary']) && !empty($episodeDetails['summary'])) { - $content .= '

Beschreibung:
' . nl2br(htmlspecialchars($episodeDetails['summary'])) . '

'; - } - - // Episode-Infos - $content .= '

'; - if (!empty($video['number'])) { - $content .= 'Episode: ' . htmlspecialchars($video['number']) . '
'; - } - if (!empty($video['name'])) { - $content .= 'Titel: ' . htmlspecialchars($video['name']) . '
'; - } - if (!empty($video['seasonTitle'])) { - $content .= 'Staffel/Abschnitt: ' . htmlspecialchars($video['seasonTitle']) . '
'; - } - if (isset($video['duration'])) { - $minutes = floor($video['duration'] / 60); - $seconds = $video['duration'] % 60; - $content .= 'Dauer: ' . $minutes . ':' . sprintf('%02d', $seconds) . ' Min.
'; - } - if (isset($episodeDetails['rating'])) { - $content .= 'Bewertung: ' . $episodeDetails['rating'] . '/5'; - if (isset($episodeDetails['ratingsCount'])) { - $content .= ' (' . $episodeDetails['ratingsCount'] . ' Bewertungen)'; - } - $content .= '
'; - } - $content .= '

'; - - // Verfügbarkeit - if (isset($video['free']) || isset($video['freeWithAds'])) { - $content .= '

Verfügbarkeit: '; - if (!empty($video['free'])) { - $content .= 'Kostenlos'; - } elseif (!empty($video['freeWithAds'])) { - $content .= 'Kostenlos mit Werbung'; - } else { - $content .= 'Premium'; - } - $content .= '

'; - } - - // Show-Info (falls verfügbar) - if (isset($episodeDetails['show']['summary']) && !empty($episodeDetails['show']['summary'])) { - $content .= '

Über die Serie:
' . nl2br(htmlspecialchars($episodeDetails['show']['summary'])) . '

'; + $content .= '

' . nl2br(htmlspecialchars($episodeDetails['summary'])) . '

'; } $item['content'] = $content; diff --git a/DMAXBridge.php b/DMAXBridge.php index 7a49b4c..84521ef 100644 --- a/DMAXBridge.php +++ b/DMAXBridge.php @@ -24,6 +24,12 @@ class DMAXBridge extends BridgeAbstract 'TLC' => 'tlc' ], 'defaultValue' => 'dmax' + ], + 'limit' => [ + 'name' => 'Maximale Anzahl an Episoden', + 'type' => 'number', + 'required' => false, + 'defaultValue' => 20 ] ] ]; @@ -72,7 +78,10 @@ class DMAXBridge extends BridgeAbstract returnServerError('Keine Episoden gefunden.'); } - foreach ($json['blocks'][1]['items'] as $element) { + $limit = $this->getInput('limit') ?? 20; + $episodes = array_slice($json['blocks'][1]['items'], 0, (int)$limit); + + foreach ($episodes as $element) { $item = []; // Erstelle den Episodentitel @@ -89,8 +98,19 @@ class DMAXBridge extends BridgeAbstract $item['title'] = sprintf('%s %s', $this->showName, $episodeTitle); } - // Setze die Beschreibung - $item['content'] = $element['description'] ?? ''; + // Content: Bild + Beschreibung + $content = ''; + + if (isset($element['poster']['src'])) { + $content .= '' . htmlspecialchars($episodeTitle) . '
'; + } + + $description = $element['description'] ?? ''; + if (!empty($description)) { + $content .= '

' . htmlspecialchars($description) . '

'; + } + + $item['content'] = $content; // Erstelle die Episode-URL $episodeSlug = $element['alternateId'] ?? ''; diff --git a/RTLPlusBridge.php b/RTLPlusBridge.php index 6ba57ee..ac0bfee 100644 --- a/RTLPlusBridge.php +++ b/RTLPlusBridge.php @@ -214,11 +214,10 @@ class RTLPlusBridge extends BridgeAbstract } } - // Beschreibung - $description = $episode['descriptionV2'] ?? ''; - $item['content'] = '

' . htmlspecialchars($description) . '

'; + // Content: Bild + Beschreibung + $content = ''; - // Thumbnail hinzufügen + // Thumbnail zuerst $imageUrl = null; if (isset($episode['watchImages']['default']['absoluteUri'])) { $imageUrl = $episode['watchImages']['default']['absoluteUri']; @@ -227,10 +226,18 @@ class RTLPlusBridge extends BridgeAbstract } if ($imageUrl) { - $item['content'] .= '

' . htmlspecialchars($episodeTitle) . '

'; + $content .= '' . htmlspecialchars($episodeTitle) . '
'; $item['enclosures'] = [$imageUrl]; } + // Beschreibung unter dem Bild + $description = $episode['descriptionV2'] ?? ''; + if (!empty($description)) { + $content .= '

' . htmlspecialchars($description) . '

'; + } + + $item['content'] = $content; + // URL konstruieren (zur Episode-Seite) if (isset($episode['urlData']['watchPath'])) { $item['uri'] = 'https://plus.rtl.de' . $episode['urlData']['watchPath']; diff --git a/ToggoBridge.php b/ToggoBridge.php index dd2f705..bbfa342 100644 --- a/ToggoBridge.php +++ b/ToggoBridge.php @@ -17,6 +17,12 @@ class ToggoBridge extends BridgeAbstract { 'type' => 'text', 'title' => 'ID der Serie (z.B. pokemon-horizonte-die-serie-vse292)', 'required' => true + ], + 'limit' => [ + 'name' => 'Maximale Anzahl an Episoden', + 'type' => 'number', + 'required' => false, + 'defaultValue' => 20 ] ] ]; @@ -37,6 +43,11 @@ class ToggoBridge extends BridgeAbstract { usort($episodes, function($a, $b) { return ($b['earliest_start_date'] ?? 0) <=> ($a['earliest_start_date'] ?? 0); }); + + // Limitiere die Anzahl + $limit = $this->getInput('limit') ?? 20; + $episodes = array_slice($episodes, 0, (int)$limit); + foreach ($episodes as $episode) { $series_title = $episode['series_title'] ?? ''; $season_no = $episode['season_no'] ?? ''; @@ -50,11 +61,17 @@ class ToggoBridge extends BridgeAbstract { $forwardWorld = $episode['forwardWorld'] ?? ($episode['characters'][0]['forwardWorld'] ?? null); $item = []; $item['title'] = sprintf('%s S%02dE%02d %s', $series_title, $season_no, $episode_no, $title); - $item['content'] = '

' . htmlspecialchars($desc) . '

'; + + // Content: Bild + Beschreibung + $content = ''; if ($img) { - $item['content'] .= '

' . htmlspecialchars($title) . '

'; + $content .= '' . htmlspecialchars($title) . '
'; $item['enclosures'] = [$img]; } + if (!empty($desc)) { + $content .= '

' . htmlspecialchars($desc) . '

'; + } + $item['content'] = $content; if ($date) { $item['timestamp'] = $date; }