A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
feat(jellyfin): show series name on episode release tiles (#7260)
Glare16822b3218d0
diff --git a/packages/integrations/src/jellyfin/jellyfin-integration.spec.ts b/packages/integrations/src/jellyfin/jellyfin-integration.spec.tsindex 07bbd2a9d..31735397d 100644--- a/packages/integrations/src/jellyfin/jellyfin-integration.spec.ts+++ b/packages/integrations/src/jellyfin/jellyfin-integration.spec.ts@@ -1,6 +1,6 @@import { describe, expect, test } from "vitest";-import { extractHost, parseLocation } from "./jellyfin-integration";+import { extractHost, formatEpisodeSubtitle, getMediaReleaseTitle, parseLocation } from "./jellyfin-integration";describe("extractHost", () => {test("strips the port from an IPv4 endpoint", () => {@@ -63,3 +63,53 @@ describe("parseLocation", () => {expect(parseLocation("[fe80::1]:8096")).toBe("lan");});});++describe("getMediaReleaseTitle", () => {+ test("uses the series name as the title of an episode", () => {+ expect(getMediaReleaseTitle({ Type: "Episode", Name: "Ozymandias", SeriesName: "Breaking Bad" })).toBe(+ "Breaking Bad",+ );+ });++ test("falls back to the item name when the series name is missing", () => {+ expect(getMediaReleaseTitle({ Type: "Episode", Name: "Ozymandias" })).toBe("Ozymandias");+ });++ test("uses the item name for other media types", () => {+ expect(getMediaReleaseTitle({ Type: "Movie", Name: "Inception" })).toBe("Inception");+ });+});++describe("formatEpisodeSubtitle", () => {+ test("combines the season and episode number with the episode name", () => {+ expect(+ formatEpisodeSubtitle({+ Type: "Episode",+ Name: "Ozymandias",+ SeriesName: "Breaking Bad",+ ParentIndexNumber: 5,+ IndexNumber: 14,+ }),+ ).toBe("S05E14 – Ozymandias");+ });++ test("pads season and episode numbers to two digits", () => {+ expect(+ formatEpisodeSubtitle({+ Type: "Episode",+ Name: "Pilot",+ SeriesName: "Breaking Bad",+ ParentIndexNumber: 1,+ IndexNumber: 3,+ }),+ ).toBe("S01E03 – Pilot");+ });++ test("falls back to the episode name when the numbers are missing", () => {+ expect(formatEpisodeSubtitle({ Type: "Episode", Name: "Pilot", SeriesName: "Breaking Bad" })).toBe("Pilot");+ });++ test("keeps the tagline when the series name is missing", () => {+ expect(formatEpisodeSubtitle({ Type: "Episode", Name: "Pilot", Taglines: ["A tagline"] })).toBe("A tagline");+ });+});diff --git a/packages/integrations/src/jellyfin/jellyfin-integration.ts b/packages/integrations/src/jellyfin/jellyfin-integration.tsindex db81d6dfe..013e9b477 100644--- a/packages/integrations/src/jellyfin/jellyfin-integration.ts+++ b/packages/integrations/src/jellyfin/jellyfin-integration.ts@@ -65,6 +65,25 @@ export function parseLocation(remoteEndPoint: string | null | undefined): "lan"return privateAddresses.check(host, family === 4 ? "ipv4" : "ipv6") ? "lan" : "wan";}+// Episodes only carry their own name, so the show name is used as the title and the episode as the subtitle.+export const getMediaReleaseTitle = (item: BaseItemDto): string => {+ if (item.Type === "Episode" && item.SeriesName) return item.SeriesName;+ return item.Name ?? "";+};++export const formatEpisodeSubtitle = (item: BaseItemDto): string | undefined => {+ // Without a series name the title stays the item name, so the previous tagline is kept as the subtitle.+ if (!item.SeriesName) return item.Taglines?.at(0);+ const name = item.Name ?? item.EpisodeTitle ?? "";+ const season = item.ParentIndexNumber;+ const episode = item.IndexNumber;+ if (season === undefined || season === null || episode === undefined || episode === null) {+ return name || undefined;+ }+ const code = `S${String(season).padStart(2, "0")}E${String(episode).padStart(2, "0")}`;+ return name ? `${code} – ${name}` : code;+};+const authorizationPrefix = 'MediaBrowser Client="Homarr", Device="Homarr", DeviceId="homarr", Version="0.0.1"';const pendingAuthentications = new Map<string, Promise<string>>();@@ -267,25 +286,29 @@ export class JellyfinIntegration extends Integration implements IMediaServerIntedisplayedSeries.add(item.SeriesId);return [parent];});- return items.map((item) => ({- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- id: item.Id!,- type: this.mapMediaReleaseType(item.Type),- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- title: item.Name!,- subtitle: item.Taglines?.at(0),- description: item.Overview ?? undefined,- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- releaseDate: new Date(item.PremiereDate ?? item.DateCreated!),- imageUrls: {- poster: super.externalUrl(`/Items/${item.Id}/Images/Primary?maxHeight=492&maxWidth=328&quality=90`).toString(),- backdrop: this.getMediaReleaseBackdropUrl(item),- },- producer: item.Studios?.at(0)?.Name ?? undefined,- rating: item.CommunityRating?.toFixed(1),- tags: item.Genres ?? [],- href: super.externalUrl(`/web/index.html#!/details?id=${item.Id}&serverId=${item.ServerId}`).toString(),- }));+ return items.map((item) => {+ const isEpisode = item.Type === "Episode";+ return {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ id: item.Id!,+ type: this.mapMediaReleaseType(item.Type),+ title: getMediaReleaseTitle(item),+ subtitle: isEpisode ? formatEpisodeSubtitle(item) : item.Taglines?.at(0),+ description: item.Overview ?? undefined,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ releaseDate: new Date(item.PremiereDate ?? item.DateCreated!),+ imageUrls: {+ poster: super+ .externalUrl(`/Items/${item.Id}/Images/Primary?maxHeight=492&maxWidth=328&quality=90`)+ .toString(),+ backdrop: this.getMediaReleaseBackdropUrl(item),+ },+ producer: item.Studios?.at(0)?.Name ?? undefined,+ rating: item.CommunityRating?.toFixed(1),+ tags: item.Genres ?? [],+ href: super.externalUrl(`/web/index.html#!/details?id=${item.Id}&serverId=${item.ServerId}`).toString(),+ };+ });}private getMediaReleaseBackdropUrl(item: BaseItemDto) {