Enhancement: support jellyfin 10.12 breaking API changes

This commit is contained in:
shamoon
2025-12-23 12:06:12 -08:00
parent be7a00d631
commit 9ae682a9c0
9 changed files with 70 additions and 8 deletions

View File

@@ -9,11 +9,17 @@ You can create an API key from inside Jellyfin at `Settings > Advanced > Api Key
As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option. As of v0.6.11 the widget supports fields `["movies", "series", "episodes", "songs"]`. These blocks are disabled by default but can be enabled with the `enableBlocks` option, and the "Now Playing" feature (enabled by default) can be disabled with the `enableNowPlaying` option.
| Jellyfin Version | Homepage Widget Version |
| ---------------- | ----------------------- |
| < 10.12 | 1 (default) |
| >= 10.12 | 2 |
```yaml ```yaml
widget: widget:
type: jellyfin type: jellyfin
url: http://jellyfin.host.or.ip url: http://jellyfin.host.or.ip
key: apikeyapikeyapikeyapikeyapikey key: apikeyapikeyapikeyapikeyapikey
version: 2 # optional, default is 1
enableBlocks: true # optional, defaults to false enableBlocks: true # optional, defaults to false
enableNowPlaying: true # optional, defaults to true enableNowPlaying: true # optional, defaults to true
enableUser: true # optional, defaults to false enableUser: true # optional, defaults to false

View File

@@ -9,6 +9,7 @@ import { buildHighlightConfig } from "utils/highlights";
const ALIASED_WIDGETS = { const ALIASED_WIDGETS = {
pialert: "netalertx", pialert: "netalertx",
hoarder: "karakeep", hoarder: "karakeep",
jellyfin: "emby",
}; };
export default function Container({ error = false, children, service }) { export default function Container({ error = false, children, service }) {

View File

@@ -556,6 +556,7 @@ export function cleanServiceGroups(groups) {
"beszel", "beszel",
"glances", "glances",
"immich", "immich",
"jellyfin",
"komga", "komga",
"mealie", "mealie",
"pfsense", "pfsense",

View File

@@ -123,6 +123,8 @@ export default async function credentialedProxyHandler(req, res, map) {
// v1 does not require a key // v1 does not require a key
headers.Authorization = `Bearer ${widget.key}`; headers.Authorization = `Bearer ${widget.key}`;
} }
} else if (widget.type === "jellyfin") {
headers["Authorization"] = `MediaBrowser Token=${widget.key}`;
} else { } else {
headers["X-API-Key"] = `${widget.key}`; headers["X-API-Key"] = `${widget.key}`;
} }

View File

@@ -60,7 +60,7 @@ const components = {
immich: dynamic(() => import("./immich/component")), immich: dynamic(() => import("./immich/component")),
jackett: dynamic(() => import("./jackett/component")), jackett: dynamic(() => import("./jackett/component")),
jdownloader: dynamic(() => import("./jdownloader/component")), jdownloader: dynamic(() => import("./jdownloader/component")),
jellyfin: dynamic(() => import("./emby/component")), jellyfin: dynamic(() => import("./jellyfin/component")),
jellyseerr: dynamic(() => import("./jellyseerr/component")), jellyseerr: dynamic(() => import("./jellyseerr/component")),
jellystat: dynamic(() => import("./jellystat/component")), jellystat: dynamic(() => import("./jellystat/component")),
kavita: dynamic(() => import("./kavita/component")), kavita: dynamic(() => import("./kavita/component")),

View File

@@ -176,9 +176,6 @@ function SessionEntry({ playCommand, session, enableUser, showEpisodeNumber, ena
function CountBlocks({ service, countData }) { function CountBlocks({ service, countData }) {
const { t } = useTranslation(); const { t } = useTranslation();
// allows filtering
// eslint-disable-next-line no-param-reassign
if (service.widget?.type === "jellyfin") service.widget.type = "emby";
if (!countData) { if (!countData) {
return ( return (
@@ -205,22 +202,31 @@ export default function Component({ service }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { widget } = service; const { widget } = service;
const version = widget?.version ?? 1;
const useJellyfinV2 = widget?.type === "jellyfin" && version === 2;
const sessionsEndpoint = useJellyfinV2 ? "SessionsV2" : "Sessions";
const countEndpoint = useJellyfinV2 ? "CountV2" : "Count";
const commandMap = {
Pause: useJellyfinV2 ? "PauseV2" : "Pause",
Unpause: useJellyfinV2 ? "UnpauseV2" : "Unpause",
};
const enableNowPlaying = service.widget?.enableNowPlaying ?? true; const enableNowPlaying = service.widget?.enableNowPlaying ?? true;
const { const {
data: sessionsData, data: sessionsData,
error: sessionsError, error: sessionsError,
mutate: sessionMutate, mutate: sessionMutate,
} = useWidgetAPI(widget, enableNowPlaying ? "Sessions" : "", { } = useWidgetAPI(widget, enableNowPlaying ? sessionsEndpoint : "", {
refreshInterval: enableNowPlaying ? 5000 : undefined, refreshInterval: enableNowPlaying ? 5000 : undefined,
}); });
const { data: countData, error: countError } = useWidgetAPI(widget, "Count", { const { data: countData, error: countError } = useWidgetAPI(widget, countEndpoint, {
refreshInterval: 60000, refreshInterval: 60000,
}); });
async function handlePlayCommand(session, command) { async function handlePlayCommand(session, command) {
const params = getURLSearchParams(widget, command); const mappedCommand = commandMap[command] ?? command;
const params = getURLSearchParams(widget, mappedCommand);
params.append( params.append(
"segments", "segments",
JSON.stringify({ JSON.stringify({

View File

@@ -0,0 +1,3 @@
import EmbyComponent from "../emby/component";
export default EmbyComponent;

View File

@@ -0,0 +1,42 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
Sessions: {
endpoint: "emby/Sessions?api_key={key}",
},
Count: {
endpoint: "emby/Items/Counts?api_key={key}",
},
Unpause: {
method: "POST",
endpoint: "emby/Sessions/{sessionId}/Playing/Unpause?api_key={key}",
segments: ["sessionId"],
},
Pause: {
method: "POST",
endpoint: "emby/Sessions/{sessionId}/Playing/Pause?api_key={key}",
segments: ["sessionId"],
},
SessionsV2: {
endpoint: "Sessions",
},
CountV2: {
endpoint: "Items/Counts",
},
UnpauseV2: {
method: "POST",
endpoint: "Sessions/{sessionId}/Playing/Unpause",
segments: ["sessionId"],
},
PauseV2: {
method: "POST",
endpoint: "Sessions/{sessionId}/Playing/Pause",
segments: ["sessionId"],
},
},
};
export default widget;

View File

@@ -51,6 +51,7 @@ import homebridge from "./homebridge/widget";
import immich from "./immich/widget"; import immich from "./immich/widget";
import jackett from "./jackett/widget"; import jackett from "./jackett/widget";
import jdownloader from "./jdownloader/widget"; import jdownloader from "./jdownloader/widget";
import jellyfin from "./jellyfin/widget";
import jellyseerr from "./jellyseerr/widget"; import jellyseerr from "./jellyseerr/widget";
import jellystat from "./jellystat/widget"; import jellystat from "./jellystat/widget";
import karakeep from "./karakeep/widget"; import karakeep from "./karakeep/widget";
@@ -201,7 +202,7 @@ const widgets = {
immich, immich,
jackett, jackett,
jdownloader, jdownloader,
jellyfin: emby, jellyfin,
jellyseerr, jellyseerr,
jellystat, jellystat,
kavita, kavita,