fix(plex): an episode with no number is named by its title on every card

The cards, the up-next card and the mark-next label printed a question
mark where Plex has no number; the player's header already showed the
title alone. One helper (episodeNumbers/episodeName) for every place.
This commit is contained in:
2026-10-08 01:16:30 +02:00
parent a504550196
commit c32429ba69
7 changed files with 93 additions and 38 deletions
+23 -12
View File
@@ -205,20 +205,31 @@ export function useCrossfadeBackdrop(
// Series detail pages (show + season subpage): the S·E label under a resume/next-up episode.
export function epLabel(ep?: PlexCard | null): string | undefined {
if (!ep) return undefined;
if (ep.season_number != null && ep.episode_number != null)
return `S${ep.season_number} · E${ep.episode_number}`;
return ep.title;
const n = episodeNumbers(ep);
return n ? `S${n.season} · E${n.episode}` : ep.title;
}
/** An episode's line under its show's name: "S1·E4 — Title" — or the title alone when Plex has no
* number for it (a special): a template literal printed the missing one as "Enull", JSX as "E". */
export function episodeLine(ep: {
season_number?: number | null;
episode_number?: number | null;
title: string;
}): string {
if (ep.season_number == null || ep.episode_number == null) return ep.title;
return `S${ep.season_number}·E${ep.episode_number} — ${ep.title}`;
type Numbered = { season_number?: number | null; episode_number?: number | null };
/** An episode's season and episode number, or null when Plex has no number for one of them (a
* special). Every place that names an episode asks this, so a numberless one is named by its title
* alone everywhere: a template literal printed the missing number as "Enull", JSX as "E", and a
* `?? "?"` as "E?", which told the viewer nothing. */
export function episodeNumbers(ep: Numbered): { season: number; episode: number } | null {
if (ep.season_number == null || ep.episode_number == null) return null;
return { season: ep.season_number, episode: ep.episode_number };
}
/** An episode named in a line of its own ("Next: …", "Mark … watched"): "S1·E4", or its title. */
export function episodeName(ep: Numbered & { title: string }): string {
const n = episodeNumbers(ep);
return n ? `S${n.season}·E${n.episode}` : ep.title;
}
/** An episode's line under its show's name: "S1·E4 — Title", or the title alone (see above). */
export function episodeLine(ep: Numbered & { title: string }): string {
const n = episodeNumbers(ep);
return n ? `S${n.season}·E${n.episode} — ${ep.title}` : ep.title;
}
// Plex names seasons in the library's language ("Season 1", "Specials"), so a Hungarian reader got