array( 'name' => 'Show-ID', 'type' => 'number', 'required' => true, 'exampleValue' => '1333', 'title' => 'Die ID der Serie (z.B. 1333 aus der URL /video/1333-serienname/)' ) ) ); public function getIcon(){ return 'https://animationdigitalnetwork.com/favicon.ico'; } public function collectData() { $show_id = $this->getInput('show_id'); if (empty($show_id)) { returnClientError('Show-ID ist erforderlich'); } // API-Aufruf zur Seasons-API $seasonsUrl = 'https://gw.api.animationdigitalnetwork.com/video/show/' . $show_id . '/seasons?order=asc'; // Headers für API-Requests $headers = [ 'Accept-Language: de', 'x-target-distribution: de' ]; $seasonsJson = getContents($seasonsUrl, $headers); $seasonsData = json_decode($seasonsJson, true); if (!isset($seasonsData['seasons']) || !is_array($seasonsData['seasons'])) { returnServerError('Konnte Seasons-Daten nicht abrufen'); } // Alle Videos aus allen Seasons sammeln $allVideos = array(); foreach ($seasonsData['seasons'] as $season) { if (isset($season['videos']) && is_array($season['videos'])) { foreach ($season['videos'] as $video) { // Staffel-Info hinzufügen $video['seasonTitle'] = $season['title']; $video['seasonNumber'] = $season['season']; $allVideos[] = $video; } } } // Array umkehren, damit neueste Folge oben ist $allVideos = array_reverse($allVideos); // Auf maximal 20 Episoden limitieren (Performance) $allVideos = array_slice($allVideos, 0, 20); // Für jede Episode Details abrufen und Feed-Item erstellen foreach ($allVideos as $video) { $item = array(); $episodeId = $video['id']; // Episode-Details abrufen $episodeUrl = 'https://gw.api.animationdigitalnetwork.com/video/' . $episodeId . '/public'; $episodeJson = getContents($episodeUrl, $headers); $episodeData = json_decode($episodeJson, true); if (!isset($episodeData['video'])) { // Wenn Details nicht verfügbar sind, mit Basis-Infos fortfahren $episodeDetails = $video; } else { $episodeDetails = $episodeData['video']; } // Titel $item['title'] = $video['title']; // URI $item['uri'] = 'https://animationdigitalnetwork.com' . $video['urlPath']; // UID $item['uid'] = 'adn-' . $episodeId; // Timestamp if (isset($episodeDetails['releaseDate'])) { $item['timestamp'] = strtotime($episodeDetails['releaseDate']); } // Kategorien $categories = array(); if (!empty($video['seasonTitle'])) { $categories[] = $video['seasonTitle']; } if (!empty($video['seasonNumber'])) { $categories[] = 'Staffel ' . $video['seasonNumber']; } if (!empty($categories)) { $item['categories'] = $categories; } // Enclosures (Bild) if (!empty($video['image'])) { $item['enclosures'] = array($video['image']); } // Autor if (isset($episodeDetails['show']['title'])) { $item['author'] = $episodeDetails['show']['title']; } // Content aufbauen $content = ''; // Bild if (!empty($video['image'])) { $content .= '' . htmlspecialchars($item['title']) . '

'; } // Summary/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'])) . '

'; } $item['content'] = $content; $this->items[] = $item; } } public function getName() { if ($this->getInput('show_id')) { // Wenn wir Items haben, können wir den Show-Titel verwenden if (!empty($this->items) && !empty($this->items[0]['author'])) { return $this->items[0]['author'] . ' - Animation Digital Network'; } return 'Show ' . $this->getInput('show_id') . ' - Animation Digital Network'; } return parent::getName(); } }