66 lines
2.8 KiB
PHP
66 lines
2.8 KiB
PHP
<?php
|
|
class ToggoBridge extends BridgeAbstract {
|
|
const NAME = 'Toggo.de Serien RSS';
|
|
const URI = 'https://www.toggo.de/';
|
|
const DESCRIPTION = 'RSS-Feed für Serien von Toggo.de';
|
|
const MAINTAINER = 'Akamaru';
|
|
const PARAMETERS = [
|
|
[
|
|
'series_id' => [
|
|
'name' => 'Serien-ID',
|
|
'type' => 'text',
|
|
'title' => 'ID der Serie (z.B. pokemon-horizonte-die-serie-vse292)',
|
|
'required' => true
|
|
]
|
|
]
|
|
];
|
|
|
|
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);
|
|
});
|
|
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);
|
|
$item['content'] = '<p>' . htmlspecialchars($desc) . '</p>';
|
|
if ($img) {
|
|
$item['content'] .= '<p><img src="' . htmlspecialchars($img) . '" alt="' . htmlspecialchars($title) . '"></p>';
|
|
$item['enclosures'] = [$img];
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|