import type { MediaItemResponse } from "@/lib/types"; interface ChannelInfoProps { channelNumber: number; channelName: string; item: MediaItemResponse; showStartTime: string; showEndTime: string; /** Progress through the current show, 0–100 */ progress: number; } function formatEpisodeLabel(item: MediaItemResponse): string | null { if (item.content_type !== "episode") return null; const parts: string[] = []; if (item.season_number != null) parts.push(`S${item.season_number}`); if (item.episode_number != null) parts.push(`E${item.episode_number}`); return parts.length > 0 ? parts.join(" · ") : null; } export function ChannelInfo({ channelNumber, channelName, item, showStartTime, showEndTime, progress, }: ChannelInfoProps) { const clampedProgress = Math.min(100, Math.max(0, progress)); const isEpisode = item.content_type === "episode"; const episodeLabel = formatEpisodeLabel(item); // For episodes: series name as headline (fall back to episode title if missing) const headline = isEpisode && item.series_name ? item.series_name : item.title; // Subtitle: only include episode title when series name is the headline (otherwise // the title is already the headline and repeating it would duplicate it) const subtitle = isEpisode ? item.series_name ? [episodeLabel, item.title].filter(Boolean).join(" · ") : episodeLabel // title is the headline — just show S·E label : item.year ? String(item.year) : null; return (
{/* Channel badge */}
{channelNumber} {channelName}
{/* Title block */}

{headline}

{subtitle && (

{subtitle}

)}
{/* Description */} {item.description && (

{item.description}

)} {/* Genres */} {item.genres.length > 0 && (
{item.genres.slice(0, 4).map((g) => ( {g} ))}
)} {/* Progress bar */}
{showStartTime} {showEndTime}
); } export type { ChannelInfoProps };