1
0

Verbessere Beschreibungen in Feeds & setze Limits

This commit is contained in:
Akamaru
2025-11-24 00:00:00 +01:00
parent aa6f6d9992
commit 238f109644
5 changed files with 93 additions and 73 deletions

View File

@@ -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 .= '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($imageAlt) . '" /><br>';
}
// Dauer
if (isset($teaser['duration'])) {
$duration = gmdate('H:i:s', $teaser['duration']);
$content .= '<p><strong>Dauer:</strong> ' . $duration . '</p>';
}
// Verfügbar bis
if (isset($teaser['availableTo'])) {
$availableTo = date('d.m.Y H:i', strtotime($teaser['availableTo']));
$content .= '<p><strong>Verfügbar bis:</strong> ' . $availableTo . ' Uhr</p>';
}
// Untertitel verfügbar
if (isset($teaser['subtitled']) && $teaser['subtitled']) {
$content .= '<p>Untertitel verfügbar</p>';
// Episoden-Beschreibung per Detail-API abrufen
if (!empty($episodeId)) {
$synopsis = $this->getEpisodeSynopsis($episodeId);
if (!empty($synopsis)) {
$content .= '<p>' . htmlspecialchars($synopsis) . '</p>';
}
}
$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;
}
}

View File

@@ -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 .= '<img src="' . $video['image'] . '" alt="' . htmlspecialchars($item['title']) . '" style="max-width: 100%;"><br><br>';
$content .= '<img src="' . $video['image'] . '" alt="' . htmlspecialchars($item['title']) . '"><br>';
}
// Summary/Beschreibung
// Beschreibung
if (isset($episodeDetails['summary']) && !empty($episodeDetails['summary'])) {
$content .= '<p><strong>Beschreibung:</strong><br>' . nl2br(htmlspecialchars($episodeDetails['summary'])) . '</p>';
}
// Episode-Infos
$content .= '<p>';
if (!empty($video['number'])) {
$content .= '<strong>Episode:</strong> ' . htmlspecialchars($video['number']) . '<br>';
}
if (!empty($video['name'])) {
$content .= '<strong>Titel:</strong> ' . htmlspecialchars($video['name']) . '<br>';
}
if (!empty($video['seasonTitle'])) {
$content .= '<strong>Staffel/Abschnitt:</strong> ' . htmlspecialchars($video['seasonTitle']) . '<br>';
}
if (isset($video['duration'])) {
$minutes = floor($video['duration'] / 60);
$seconds = $video['duration'] % 60;
$content .= '<strong>Dauer:</strong> ' . $minutes . ':' . sprintf('%02d', $seconds) . ' Min.<br>';
}
if (isset($episodeDetails['rating'])) {
$content .= '<strong>Bewertung:</strong> ' . $episodeDetails['rating'] . '/5';
if (isset($episodeDetails['ratingsCount'])) {
$content .= ' (' . $episodeDetails['ratingsCount'] . ' Bewertungen)';
}
$content .= '<br>';
}
$content .= '</p>';
// Verfügbarkeit
if (isset($video['free']) || isset($video['freeWithAds'])) {
$content .= '<p><strong>Verfügbarkeit:</strong> ';
if (!empty($video['free'])) {
$content .= 'Kostenlos';
} elseif (!empty($video['freeWithAds'])) {
$content .= 'Kostenlos mit Werbung';
} else {
$content .= 'Premium';
}
$content .= '</p>';
}
// Show-Info (falls verfügbar)
if (isset($episodeDetails['show']['summary']) && !empty($episodeDetails['show']['summary'])) {
$content .= '<hr><p><strong>Über die Serie:</strong><br>' . nl2br(htmlspecialchars($episodeDetails['show']['summary'])) . '</p>';
$content .= '<p>' . nl2br(htmlspecialchars($episodeDetails['summary'])) . '</p>';
}
$item['content'] = $content;

View File

@@ -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 .= '<img src="' . htmlspecialchars($element['poster']['src']) . '" alt="' . htmlspecialchars($episodeTitle) . '"><br>';
}
$description = $element['description'] ?? '';
if (!empty($description)) {
$content .= '<p>' . htmlspecialchars($description) . '</p>';
}
$item['content'] = $content;
// Erstelle die Episode-URL
$episodeSlug = $element['alternateId'] ?? '';

View File

@@ -214,11 +214,10 @@ class RTLPlusBridge extends BridgeAbstract
}
}
// Beschreibung
$description = $episode['descriptionV2'] ?? '';
$item['content'] = '<p>' . htmlspecialchars($description) . '</p>';
// 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'] .= '<p><img src="' . htmlspecialchars($imageUrl) . '" alt="' . htmlspecialchars($episodeTitle) . '"></p>';
$content .= '<img src="' . htmlspecialchars($imageUrl) . '" alt="' . htmlspecialchars($episodeTitle) . '"><br>';
$item['enclosures'] = [$imageUrl];
}
// Beschreibung unter dem Bild
$description = $episode['descriptionV2'] ?? '';
if (!empty($description)) {
$content .= '<p>' . htmlspecialchars($description) . '</p>';
}
$item['content'] = $content;
// URL konstruieren (zur Episode-Seite)
if (isset($episode['urlData']['watchPath'])) {
$item['uri'] = 'https://plus.rtl.de' . $episode['urlData']['watchPath'];

View File

@@ -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'] = '<p>' . htmlspecialchars($desc) . '</p>';
// Content: Bild + Beschreibung
$content = '';
if ($img) {
$item['content'] .= '<p><img src="' . htmlspecialchars($img) . '" alt="' . htmlspecialchars($title) . '"></p>';
$content .= '<img src="' . htmlspecialchars($img) . '" alt="' . htmlspecialchars($title) . '"><br>';
$item['enclosures'] = [$img];
}
if (!empty($desc)) {
$content .= '<p>' . htmlspecialchars($desc) . '</p>';
}
$item['content'] = $content;
if ($date) {
$item['timestamp'] = $date;
}