[
'name' => 'Serien-ID',
'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
]
]
];
public function collectData() {
$series_id = $this->getInput('series_id');
if (empty($series_id)) {
return;
}
$url = 'https://production-n.toggo.de/api/assetstore/vod/asset/' . $series_id . '?filter=rootParentTypes[not|hidden]&availableAs=fvod,catchup';
$json = getContents($url);
$data = json_decode($json, true);
if (!$data || !isset($data['data']['episodes'])) {
return;
}
$episodes = $data['data']['episodes'];
// Sortiere nach Startdatum absteigend (neueste zuerst)
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'] ?? '';
$episode_no = $episode['episode_no'] ?? '';
$title = $episode['title'] ?? '';
$desc = $episode['description'] ?? '';
$img = $episode['images']['Thumbnail'] ?? '';
$date = $episode['earliest_start_date'] ?? null;
$u_name = $episode['u_name'] ?? '';
$series_uname = $episode['series_uname'] ?? $series_id;
$forwardWorld = $episode['forwardWorld'] ?? ($episode['characters'][0]['forwardWorld'] ?? null);
$item = [];
$item['title'] = sprintf('%s S%02dE%02d %s', $series_title, $season_no, $episode_no, $title);
// Content: Bild + Beschreibung
$content = '';
if ($img) {
$content .= '
';
$item['enclosures'] = [$img];
}
if (!empty($desc)) {
$content .= '
' . htmlspecialchars($desc) . '
'; } $item['content'] = $content; $item['author'] = 'Toggo'; if ($date) { $item['timestamp'] = $date; } // Link zur Folge if ($u_name && $series_uname && $forwardWorld) { $item['uri'] = 'https://www.toggo.de/' . $forwardWorld . '/serien/' . $series_uname . '/folge/' . $u_name; } elseif ($u_name && $series_uname) { $item['uri'] = 'https://www.toggo.de/serien/' . $series_uname . '/folge/' . $u_name; } else { $item['uri'] = self::URI; } $this->items[] = $item; } } }