mirror of
https://github.com/gethomepage/homepage.git
synced 2025-07-09 03:04:18 -04:00
Feature: Jellystat widget (#5185)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
41dc2e77cb
commit
7e8752243c
18
docs/widgets/services/jellystat.md
Normal file
18
docs/widgets/services/jellystat.md
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
title: Jellystat
|
||||
description: Jellystat Widget Configuration
|
||||
---
|
||||
|
||||
Learn more about [Jellystat](https://github.com/CyferShepard/Jellystat). The widget supports (at least) Jellystat version 1.1.6
|
||||
|
||||
You can create an API key from inside Jellystat at `Settings > API Key`.
|
||||
|
||||
Allowed fields: `["songs", "movies", "episodes", "other"]`.
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: jellystat
|
||||
url: http://jellystat.host.or.ip
|
||||
key: apikeyapikeyapikeyapikeyapikey
|
||||
days: 30 # optional, defaults to 30
|
||||
```
|
@ -1042,5 +1042,11 @@
|
||||
"downloads": "Downloads",
|
||||
"uploads": "Uploads",
|
||||
"sharedFiles": "Files"
|
||||
},
|
||||
"jellystat": {
|
||||
"songs": "Songs",
|
||||
"movies": "Movies",
|
||||
"episodes": "Episodes",
|
||||
"other": "Other"
|
||||
}
|
||||
}
|
||||
|
@ -331,6 +331,9 @@ export function cleanServiceGroups(groups) {
|
||||
referrerPolicy,
|
||||
src,
|
||||
|
||||
// jellystat
|
||||
days,
|
||||
|
||||
// kopia
|
||||
snapshotHost,
|
||||
snapshotPath,
|
||||
@ -563,6 +566,9 @@ export function cleanServiceGroups(groups) {
|
||||
if (type === "spoolman") {
|
||||
if (spoolIds !== undefined) widget.spoolIds = spoolIds;
|
||||
}
|
||||
if (type === "jellystat") {
|
||||
if (days !== undefined) widget.days = parseInt(days, 10);
|
||||
}
|
||||
return widget;
|
||||
});
|
||||
return cleanedService;
|
||||
|
@ -65,7 +65,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
||||
} else if (widget.type === "proxmoxbackupserver") {
|
||||
delete headers["Content-Type"];
|
||||
headers.Authorization = `PBSAPIToken=${widget.username}:${widget.password}`;
|
||||
} else if (widget.type === "autobrr") {
|
||||
} else if (["autobrr", "jellystat"].includes(widget.type)) {
|
||||
headers["X-API-Token"] = `${widget.key}`;
|
||||
} else if (widget.type === "tubearchivist") {
|
||||
headers.Authorization = `Token ${widget.key}`;
|
||||
|
@ -59,6 +59,7 @@ const components = {
|
||||
jdownloader: dynamic(() => import("./jdownloader/component")),
|
||||
jellyfin: dynamic(() => import("./emby/component")),
|
||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||
jellystat: dynamic(() => import("./jellystat/component")),
|
||||
kavita: dynamic(() => import("./kavita/component")),
|
||||
komga: dynamic(() => import("./komga/component")),
|
||||
kopia: dynamic(() => import("./kopia/component")),
|
||||
|
38
src/widgets/jellystat/component.jsx
Normal file
38
src/widgets/jellystat/component.jsx
Normal file
@ -0,0 +1,38 @@
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
// Days validation
|
||||
if (!(Number.isInteger(widget.days) && 0 < widget.days)) widget.days = 30;
|
||||
|
||||
const { data: viewsData, error: viewsError } = useWidgetAPI(widget, "getViewsByLibraryType", { days: widget.days });
|
||||
|
||||
const error = viewsError || viewsData?.message;
|
||||
if (error) {
|
||||
return <Container service={service} error={error} />;
|
||||
}
|
||||
|
||||
if (!viewsData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="jellystat.songs" />
|
||||
<Block label="jellystat.movies" />
|
||||
<Block label="jellystat.episodes" />
|
||||
<Block label="jellystat.other" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="jellystat.songs" value={viewsData.Audio} />
|
||||
<Block label="jellystat.movies" value={viewsData.Movie} />
|
||||
<Block label="jellystat.episodes" value={viewsData.Series} />
|
||||
<Block label="jellystat.other" value={viewsData.Other} />
|
||||
</Container>
|
||||
);
|
||||
}
|
15
src/widgets/jellystat/widget.js
Normal file
15
src/widgets/jellystat/widget.js
Normal file
@ -0,0 +1,15 @@
|
||||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: credentialedProxyHandler,
|
||||
|
||||
mappings: {
|
||||
getViewsByLibraryType: {
|
||||
endpoint: "stats/getViewsByLibraryType",
|
||||
params: ["days"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
@ -49,6 +49,7 @@ import immich from "./immich/widget";
|
||||
import jackett from "./jackett/widget";
|
||||
import jdownloader from "./jdownloader/widget";
|
||||
import jellyseerr from "./jellyseerr/widget";
|
||||
import jellystat from "./jellystat/widget";
|
||||
import karakeep from "./karakeep/widget";
|
||||
import kavita from "./kavita/widget";
|
||||
import komga from "./komga/widget";
|
||||
@ -190,6 +191,7 @@ const widgets = {
|
||||
jdownloader,
|
||||
jellyfin: emby,
|
||||
jellyseerr,
|
||||
jellystat,
|
||||
kavita,
|
||||
komga,
|
||||
kopia,
|
||||
|
Loading…
x
Reference in New Issue
Block a user