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, refreshInterval: 5000,
}); });
const {
data: countData,
error: countError,
} = useWidgetAPI(widget, "Count", {
refreshInterval: 600000,
});
async function handlePlayCommand(session, command) { async function handlePlayCommand(session, command) {
const url = formatProxyUrlWithSegments(widget, "PlayControl", { const url = formatProxyUrlWithSegments(widget, "PlayControl", {
sessionId: session.Id, 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) { if (sessionsError) {
return <Container error={sessionsError} />; return <Container error={sessionsError} />;
} }

View File

@ -8,6 +8,15 @@ const widget = {
Sessions: { Sessions: {
endpoint: "Sessions", endpoint: "Sessions",
}, },
Count: {
endpoint: "Items/Counts",
validate: [
"MovieCount",
"SeriesCount",
"EpisodeCount",
"SongCount"
]
},
PlayControl: { PlayControl: {
method: "POST", method: "POST",
endpoint: "Sessions/{sessionId}/Playing/{command}", endpoint: "Sessions/{sessionId}/Playing/{command}",