Neu: ARD Mediathek Serien Bridge
This commit is contained in:
174
ARDMediathekSeriesBridge.php
Normal file
174
ARDMediathekSeriesBridge.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
class ARDMediathekSeriesBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'ARD Mediathek Serien Bridge';
|
||||
const URI = 'https://www.ardmediathek.de';
|
||||
const API_URI = 'https://api.ardmediathek.de/page-gateway/pages/ard/grouping/';
|
||||
const DESCRIPTION = 'Gibt die neuesten Episoden einer Serie aus der ARD Mediathek zurück.';
|
||||
const MAINTAINER = 'Akamaru';
|
||||
const CACHE_TIMEOUT = 3600; // 1 Stunde
|
||||
|
||||
const PARAMETERS = [
|
||||
'Serie' => [
|
||||
'series_id' => [
|
||||
'name' => 'Serien-ID (z.B. "Y3JpZDovL2hyLW9ubGluZS8zODIyMDAzMw")',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'exampleValue' => 'Y3JpZDovL2hyLW9ubGluZS8zODIyMDAzMw'
|
||||
],
|
||||
'limit' => [
|
||||
'name' => 'Maximale Anzahl an Episoden',
|
||||
'type' => 'number',
|
||||
'required' => false,
|
||||
'defaultValue' => 20
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return 'https://www.google.com/s2/favicons?domain=www.ardmediathek.de&sz=32';
|
||||
}
|
||||
private $seriesTitle = '';
|
||||
private $seriesDescription = '';
|
||||
|
||||
public function getName()
|
||||
{
|
||||
if (!empty($this->seriesTitle)) {
|
||||
return $this->seriesTitle . ' - ARD Mediathek';
|
||||
}
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$seriesId = $this->getInput('series_id');
|
||||
$limit = $this->getInput('limit') ?? 20;
|
||||
|
||||
if (empty($seriesId)) {
|
||||
returnClientError('Ungültige Serien-ID.');
|
||||
}
|
||||
|
||||
$apiUrl = self::API_URI . urlencode($seriesId);
|
||||
$jsonData = getContents($apiUrl);
|
||||
$data = json_decode($jsonData, true);
|
||||
|
||||
if (!$data) {
|
||||
returnServerError('Keine Daten von der ARD Mediathek API erhalten.');
|
||||
}
|
||||
|
||||
// Extrahiere Serien-Informationen
|
||||
$this->seriesTitle = $data['title'] ?? 'Unbekannte Serie';
|
||||
$this->seriesDescription = $data['synopsis'] ?? '';
|
||||
|
||||
// Die Episoden befinden sich im ersten Widget unter 'teasers'
|
||||
if (!isset($data['widgets'][0]['teasers']) || !is_array($data['widgets'][0]['teasers'])) {
|
||||
returnServerError('Keine Episoden gefunden.');
|
||||
}
|
||||
|
||||
$teasers = $data['widgets'][0]['teasers'];
|
||||
|
||||
// Sortiere nach Sendedatum (neueste zuerst)
|
||||
usort($teasers, function ($a, $b) {
|
||||
$timeA = strtotime($a['broadcastedOn'] ?? 0);
|
||||
$timeB = strtotime($b['broadcastedOn'] ?? 0);
|
||||
return $timeB - $timeA;
|
||||
});
|
||||
|
||||
// Limitiere die Anzahl der Episoden
|
||||
$teasers = array_slice($teasers, 0, $limit);
|
||||
|
||||
foreach ($teasers as $teaser) {
|
||||
$item = [];
|
||||
|
||||
// Titel der Episode
|
||||
$item['title'] = $teaser['longTitle'] ?? $teaser['mediumTitle'] ?? $teaser['shortTitle'] ?? 'Unbekannter Titel';
|
||||
|
||||
// URL zur Episode
|
||||
$episodeId = $teaser['id'] ?? '';
|
||||
if (!empty($episodeId)) {
|
||||
$item['uri'] = self::URI . '/video/' . $episodeId;
|
||||
} else {
|
||||
$item['uri'] = self::URI;
|
||||
}
|
||||
|
||||
// Zeitstempel
|
||||
if (isset($teaser['broadcastedOn'])) {
|
||||
$item['timestamp'] = strtotime($teaser['broadcastedOn']);
|
||||
}
|
||||
|
||||
// Eindeutige ID
|
||||
$item['uid'] = $episodeId;
|
||||
|
||||
// Sender/Autor
|
||||
if (isset($teaser['publicationService']['name'])) {
|
||||
$item['author'] = $teaser['publicationService']['name'];
|
||||
}
|
||||
|
||||
// Content: Bild + Beschreibung + Verfügbarkeit
|
||||
$content = '';
|
||||
|
||||
// Vorschaubild
|
||||
if (isset($teaser['images']['aspect16x9']['src'])) {
|
||||
$imageUrl = $teaser['images']['aspect16x9']['src'];
|
||||
// Setze eine vernünftige Bildbreite
|
||||
$imageUrl = str_replace('{width}', '960', $imageUrl);
|
||||
$imageAlt = $teaser['images']['aspect16x9']['alt'] ?? '';
|
||||
$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>';
|
||||
}
|
||||
|
||||
$item['content'] = $content;
|
||||
|
||||
// Enclosure für das Vorschaubild
|
||||
if (isset($teaser['images']['aspect16x9']['src'])) {
|
||||
$imageUrl = str_replace('{width}', '960', $teaser['images']['aspect16x9']['src']);
|
||||
$item['enclosures'] = [$imageUrl];
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI()
|
||||
{
|
||||
$seriesId = $this->getInput('series_id');
|
||||
|
||||
if (empty($seriesId)) {
|
||||
return self::URI;
|
||||
}
|
||||
|
||||
return self::URI . '/serie/' . $seriesId;
|
||||
}
|
||||
|
||||
public function detectParameters($url)
|
||||
{
|
||||
// Versuche die Serien-ID aus verschiedenen ARD Mediathek URL-Formaten zu extrahieren
|
||||
// Format 1: https://www.ardmediathek.de/serie/Y3JpZDovL2hyLW9ubGluZS8zODIyMDAzMw
|
||||
// Format 2: https://www.ardmediathek.de/serie/name/staffel-X/Y3JpZDovL2hyLW9ubGluZS8zODIyMDAzMw/X
|
||||
if (preg_match('#ardmediathek\.de/serie/(?:[^/]+/(?:staffel-\d+/)?)?([A-Za-z0-9_-]+)(?:/\d+)?#', $url, $matches)) {
|
||||
return [
|
||||
'series_id' => $matches[1]
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,12 @@ Diese Sammlung enthält verschiedene Bridge-Implementierungen für RSS-Bridge, u
|
||||
- **Parameter**:
|
||||
- **Show-ID**: Die ID der Serie (z.B. 1333 aus der URL /video/1333-serienname/)
|
||||
|
||||
### [ARD Mediathek Serien Bridge](https://bridge.ponywave.de/#bridge-ARDMediathekSeriesBridge) (Von Akamaru)
|
||||
- **Beschreibung**: Gibt die neuesten Episoden einer Serie aus der ARD Mediathek zurück
|
||||
- **Parameter**:
|
||||
- **Serien-ID**: Die ID der Serie (z.B. "Y3JpZDovL2hyLW9ubGluZS8zODIyMDAzMw" aus der URL /serie/Y3JpZDovL2hyLW9ubGluZS8zODIyMDAzMw)
|
||||
- **Limit** (optional): Maximale Anzahl an Episoden (Standard: 20)
|
||||
|
||||
### [Ananta Game News Bridge](https://bridge.ponywave.de/#bridge-AnantaBridge) (Von Akamaru)
|
||||
- **Beschreibung**: Zeigt die neuesten Nachrichten von Ananta Game
|
||||
|
||||
|
||||
Reference in New Issue
Block a user