This commit is contained in:
Gogs
2026-07-09 14:36:47 +02:00
parent 9831469bd0
commit 2df690ba11
10 changed files with 724 additions and 36 deletions
+75 -1
View File
@@ -62,7 +62,13 @@ class ProgrammeService
continue;
}
foreach ($channel['programmes'] ?? [] as $p) {
$programmes = $channel['programmes'] ?? [];
usort($programmes, function ($a, $b) {
return ((int)($a['start'] ?? 0)) <=> ((int)($b['start'] ?? 0));
});
foreach ($programmes as $index => $p) {
$start = (int)($p['start'] ?? 0);
$stop = (int)($p['stop'] ?? 0);
@@ -71,21 +77,36 @@ class ProgrammeService
$elapsed = max(0, $now - $start);
$percent = min(100, round(($elapsed / $duration) * 100));
$next = $programmes[$index + 1] ?? null;
$items[] = [
'channel_id' => $id,
'channel_name' => $cfg['name'] ?? $channel['name'] ?? $id,
'channel_icon' => $cfg['icon'] ?? $channel['icon'] ?? '',
'channel_number' => (int)($cfg['number'] ?? 999999),
'favorite' => (bool)($cfg['favorite'] ?? false),
'title' => $p['title'] ?? '',
'subtitle' => $p['subtitle'] ?? '',
'description' => $p['description'] ?? '',
'category' => $p['category'] ?? '',
'genre_icon' => $this->getGenreIcon($p['category'] ?? ''),
'metadata' => $p['metadata'] ?? [],
'year' => $p['year'] ?? '',
'rating' => $p['rating'] ?? '',
'episode' => $p['episode'] ?? '',
'quality' => $this->detectQuality($p),
'start' => $start,
'stop' => $stop,
'percent' => $percent,
'remaining_minutes' => max(0, (int)ceil(($stop - $now) / 60)),
'next_title' => $next['title'] ?? '',
'next_subtitle' => $next['subtitle'] ?? '',
'next_start' => isset($next['start']) ? (int)$next['start'] : null,
'next_stop' => isset($next['stop']) ? (int)$next['stop'] : null,
'next_category' => $next['category'] ?? '',
];
break;
@@ -191,4 +212,57 @@ class ProgrammeService
return $items;
}
private function getGenreIcon(string $category): string
{
$category = mb_strtolower($category);
return match (true) {
str_contains($category, 'film'),
str_contains($category, 'movie'),
str_contains($category, 'kino') => '🎬',
str_contains($category, 'serie'),
str_contains($category, 'series') => '📺',
str_contains($category, 'sport'),
str_contains($category, 'football'),
str_contains($category, 'fußball'),
str_contains($category, 'fussball') => '⚽',
str_contains($category, 'news'),
str_contains($category, 'nachrichten'),
str_contains($category, 'journal') => '📰',
str_contains($category, 'doku'),
str_contains($category, 'documentary') => '🌍',
str_contains($category, 'kinder'),
str_contains($category, 'kids'),
str_contains($category, 'children') => '🧸',
str_contains($category, 'musik'),
str_contains($category, 'music') => '🎵',
default => '▶',
};
}
private function detectQuality(array $programme): string
{
$text = mb_strtolower(
($programme['title'] ?? '') . ' ' .
($programme['subtitle'] ?? '') . ' ' .
($programme['description'] ?? '')
);
return match (true) {
str_contains($text, 'uhd'),
str_contains($text, '4k') => 'UHD',
str_contains($text, 'hd') => 'HD',
default => '',
};
}
}