From dbd59f8d8cab35fbc333e3e520b8a22dd8dc5137 Mon Sep 17 00:00:00 2001 From: jagadam97 Date: Sat, 11 Mar 2023 05:05:44 +0530 Subject: [PATCH] added count for movies, series, Episodes and Music to jellyfin widgets --- src/widgets/emby/component.jsx | 22 ++++++++++++++++++++++ src/widgets/emby/widget.js | 33 +++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/widgets/emby/component.jsx b/src/widgets/emby/component.jsx index a61cd7aa..79fe2240 100644 --- a/src/widgets/emby/component.jsx +++ b/src/widgets/emby/component.jsx @@ -161,6 +161,13 @@ export default function Component({ service }) { refreshInterval: 5000, }); + const { + data: countData, + error: countError, + } = useWidgetAPI(widget, "Count", { + refreshInterval: 600000, + }); + async function handlePlayCommand(session, command) { const url = formatProxyUrlWithSegments(widget, "PlayControl", { sessionId: session.Id, @@ -171,6 +178,21 @@ export default function Component({ service }) { }); } + if (countError) { + return ; + } + + if (countData){ + return ( + + + + + + + ); + } + if (sessionsError) { return ; } diff --git a/src/widgets/emby/widget.js b/src/widgets/emby/widget.js index 27fc749b..1295ddda 100644 --- a/src/widgets/emby/widget.js +++ b/src/widgets/emby/widget.js @@ -1,19 +1,28 @@ import genericProxyHandler from "utils/proxy/handlers/generic"; const widget = { - api: "{url}/emby/{endpoint}?api_key={key}", - proxyHandler: genericProxyHandler, + api: "{url}/emby/{endpoint}?api_key={key}", + proxyHandler: genericProxyHandler, - mappings: { - Sessions: { - endpoint: "Sessions", + mappings: { + Sessions: { + endpoint: "Sessions", + }, + Count: { + endpoint: "Items/Counts", + validate: [ + "MovieCount", + "SeriesCount", + "EpisodeCount", + "SongCount" + ] + }, + PlayControl: { + method: "POST", + endpoint: "Sessions/{sessionId}/Playing/{command}", + segments: ["sessionId", "command"], + }, }, - PlayControl: { - method: "POST", - endpoint: "Sessions/{sessionId}/Playing/{command}", - segments: ["sessionId", "command"], - }, - }, }; -export default widget; +export default widget; \ No newline at end of file