mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-08 00:40:52 +08:00
Enhancement: support jellyfin 10.12 breaking API changes
This commit is contained in:
@@ -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.
|
||||
|
||||
| Jellyfin Version | Homepage Widget Version |
|
||||
| ---------------- | ----------------------- |
|
||||
| < 10.12 | 1 (default) |
|
||||
| >= 10.12 | 2 |
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: jellyfin
|
||||
url: http://jellyfin.host.or.ip
|
||||
key: apikeyapikeyapikeyapikeyapikey
|
||||
version: 2 # optional, default is 1
|
||||
enableBlocks: true # optional, defaults to false
|
||||
enableNowPlaying: true # optional, defaults to true
|
||||
enableUser: true # optional, defaults to false
|
||||
|
||||
@@ -9,6 +9,7 @@ import { buildHighlightConfig } from "utils/highlights";
|
||||
const ALIASED_WIDGETS = {
|
||||
pialert: "netalertx",
|
||||
hoarder: "karakeep",
|
||||
jellyfin: "emby",
|
||||
};
|
||||
|
||||
export default function Container({ error = false, children, service }) {
|
||||
|
||||
@@ -556,6 +556,7 @@ export function cleanServiceGroups(groups) {
|
||||
"beszel",
|
||||
"glances",
|
||||
"immich",
|
||||
"jellyfin",
|
||||
"komga",
|
||||
"mealie",
|
||||
"pfsense",
|
||||
|
||||
@@ -123,6 +123,8 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
// v1 does not require a key
|
||||
headers.Authorization = `Bearer ${widget.key}`;
|
||||
}
|
||||
} else if (widget.type === "jellyfin") {
|
||||
headers["Authorization"] = `MediaBrowser Token=${widget.key}`;
|
||||
} else {
|
||||
headers["X-API-Key"] = `${widget.key}`;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ const components = {
|
||||
immich: dynamic(() => import("./immich/component")),
|
||||
jackett: dynamic(() => import("./jackett/component")),
|
||||
jdownloader: dynamic(() => import("./jdownloader/component")),
|
||||
jellyfin: dynamic(() => import("./emby/component")),
|
||||
jellyfin: dynamic(() => import("./jellyfin/component")),
|
||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||
jellystat: dynamic(() => import("./jellystat/component")),
|
||||
kavita: dynamic(() => import("./kavita/component")),
|
||||
|
||||
@@ -176,9 +176,6 @@ function SessionEntry({ playCommand, session, enableUser, showEpisodeNumber, ena
|
||||
|
||||
function CountBlocks({ service, countData }) {
|
||||
const { t } = useTranslation();
|
||||
// allows filtering
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
if (service.widget?.type === "jellyfin") service.widget.type = "emby";
|
||||
|
||||
if (!countData) {
|
||||
return (
|
||||
@@ -205,22 +202,31 @@ export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
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 {
|
||||
data: sessionsData,
|
||||
error: sessionsError,
|
||||
mutate: sessionMutate,
|
||||
} = useWidgetAPI(widget, enableNowPlaying ? "Sessions" : "", {
|
||||
} = useWidgetAPI(widget, enableNowPlaying ? sessionsEndpoint : "", {
|
||||
refreshInterval: enableNowPlaying ? 5000 : undefined,
|
||||
});
|
||||
|
||||
const { data: countData, error: countError } = useWidgetAPI(widget, "Count", {
|
||||
const { data: countData, error: countError } = useWidgetAPI(widget, countEndpoint, {
|
||||
refreshInterval: 60000,
|
||||
});
|
||||
|
||||
async function handlePlayCommand(session, command) {
|
||||
const params = getURLSearchParams(widget, command);
|
||||
const mappedCommand = commandMap[command] ?? command;
|
||||
const params = getURLSearchParams(widget, mappedCommand);
|
||||
params.append(
|
||||
"segments",
|
||||
JSON.stringify({
|
||||
|
||||
3
src/widgets/jellyfin/component.jsx
Normal file
3
src/widgets/jellyfin/component.jsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import EmbyComponent from "../emby/component";
|
||||
|
||||
export default EmbyComponent;
|
||||
42
src/widgets/jellyfin/widget.js
Normal file
42
src/widgets/jellyfin/widget.js
Normal 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;
|
||||
@@ -51,6 +51,7 @@ import homebridge from "./homebridge/widget";
|
||||
import immich from "./immich/widget";
|
||||
import jackett from "./jackett/widget";
|
||||
import jdownloader from "./jdownloader/widget";
|
||||
import jellyfin from "./jellyfin/widget";
|
||||
import jellyseerr from "./jellyseerr/widget";
|
||||
import jellystat from "./jellystat/widget";
|
||||
import karakeep from "./karakeep/widget";
|
||||
@@ -201,7 +202,7 @@ const widgets = {
|
||||
immich,
|
||||
jackett,
|
||||
jdownloader,
|
||||
jellyfin: emby,
|
||||
jellyfin,
|
||||
jellyseerr,
|
||||
jellystat,
|
||||
kavita,
|
||||
|
||||
Reference in New Issue
Block a user