added count for movies, series, Episodes and Music to jellyfin widgets

This commit is contained in:
jagadam97 2023-03-11 05:05:44 +05:30
parent fb15f5dbc9
commit dbd59f8d8c
2 changed files with 43 additions and 12 deletions

View File

@ -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 <Container error={countError} />;
}
if (countData){
return (
<Container service={service}>
<Block label="emby.Movies" value={t("common.number", { value: countData.MovieCount })} />
<Block label="emby.Series" value={t("common.number", { value: countData.SeriesCount })} />
<Block label="emby.Episodes" value={t("common.number", { value: countData.EpisodeCount })} />
<Block label="emby.Songs" value={t("common.number", { value: countData.SongCount })} />
</Container>
);
}
if (sessionsError) {
return <Container error={sessionsError} />;
}

View File

@ -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;