mirror of
				https://github.com/gethomepage/homepage.git
				synced 2025-11-03 19:17:03 -05: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",
 | 
					        "downloads": "Downloads",
 | 
				
			||||||
        "uploads": "Uploads",
 | 
					        "uploads": "Uploads",
 | 
				
			||||||
        "sharedFiles": "Files"
 | 
					        "sharedFiles": "Files"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "jellystat": {
 | 
				
			||||||
 | 
					        "songs": "Songs",
 | 
				
			||||||
 | 
					        "movies": "Movies",
 | 
				
			||||||
 | 
					        "episodes": "Episodes",
 | 
				
			||||||
 | 
					        "other": "Other"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -331,6 +331,9 @@ export function cleanServiceGroups(groups) {
 | 
				
			|||||||
          referrerPolicy,
 | 
					          referrerPolicy,
 | 
				
			||||||
          src,
 | 
					          src,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          // jellystat
 | 
				
			||||||
 | 
					          days,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // kopia
 | 
					          // kopia
 | 
				
			||||||
          snapshotHost,
 | 
					          snapshotHost,
 | 
				
			||||||
          snapshotPath,
 | 
					          snapshotPath,
 | 
				
			||||||
@ -563,6 +566,9 @@ export function cleanServiceGroups(groups) {
 | 
				
			|||||||
        if (type === "spoolman") {
 | 
					        if (type === "spoolman") {
 | 
				
			||||||
          if (spoolIds !== undefined) widget.spoolIds = spoolIds;
 | 
					          if (spoolIds !== undefined) widget.spoolIds = spoolIds;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (type === "jellystat") {
 | 
				
			||||||
 | 
					          if (days !== undefined) widget.days = parseInt(days, 10);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return widget;
 | 
					        return widget;
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      return cleanedService;
 | 
					      return cleanedService;
 | 
				
			||||||
 | 
				
			|||||||
@ -65,7 +65,7 @@ export default async function credentialedProxyHandler(req, res, map) {
 | 
				
			|||||||
      } else if (widget.type === "proxmoxbackupserver") {
 | 
					      } else if (widget.type === "proxmoxbackupserver") {
 | 
				
			||||||
        delete headers["Content-Type"];
 | 
					        delete headers["Content-Type"];
 | 
				
			||||||
        headers.Authorization = `PBSAPIToken=${widget.username}:${widget.password}`;
 | 
					        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}`;
 | 
					        headers["X-API-Token"] = `${widget.key}`;
 | 
				
			||||||
      } else if (widget.type === "tubearchivist") {
 | 
					      } else if (widget.type === "tubearchivist") {
 | 
				
			||||||
        headers.Authorization = `Token ${widget.key}`;
 | 
					        headers.Authorization = `Token ${widget.key}`;
 | 
				
			||||||
 | 
				
			|||||||
@ -59,6 +59,7 @@ const components = {
 | 
				
			|||||||
  jdownloader: dynamic(() => import("./jdownloader/component")),
 | 
					  jdownloader: dynamic(() => import("./jdownloader/component")),
 | 
				
			||||||
  jellyfin: dynamic(() => import("./emby/component")),
 | 
					  jellyfin: dynamic(() => import("./emby/component")),
 | 
				
			||||||
  jellyseerr: dynamic(() => import("./jellyseerr/component")),
 | 
					  jellyseerr: dynamic(() => import("./jellyseerr/component")),
 | 
				
			||||||
 | 
					  jellystat: dynamic(() => import("./jellystat/component")),
 | 
				
			||||||
  kavita: dynamic(() => import("./kavita/component")),
 | 
					  kavita: dynamic(() => import("./kavita/component")),
 | 
				
			||||||
  komga: dynamic(() => import("./komga/component")),
 | 
					  komga: dynamic(() => import("./komga/component")),
 | 
				
			||||||
  kopia: dynamic(() => import("./kopia/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 jackett from "./jackett/widget";
 | 
				
			||||||
import jdownloader from "./jdownloader/widget";
 | 
					import jdownloader from "./jdownloader/widget";
 | 
				
			||||||
import jellyseerr from "./jellyseerr/widget";
 | 
					import jellyseerr from "./jellyseerr/widget";
 | 
				
			||||||
 | 
					import jellystat from "./jellystat/widget";
 | 
				
			||||||
import karakeep from "./karakeep/widget";
 | 
					import karakeep from "./karakeep/widget";
 | 
				
			||||||
import kavita from "./kavita/widget";
 | 
					import kavita from "./kavita/widget";
 | 
				
			||||||
import komga from "./komga/widget";
 | 
					import komga from "./komga/widget";
 | 
				
			||||||
@ -190,6 +191,7 @@ const widgets = {
 | 
				
			|||||||
  jdownloader,
 | 
					  jdownloader,
 | 
				
			||||||
  jellyfin: emby,
 | 
					  jellyfin: emby,
 | 
				
			||||||
  jellyseerr,
 | 
					  jellyseerr,
 | 
				
			||||||
 | 
					  jellystat,
 | 
				
			||||||
  kavita,
 | 
					  kavita,
 | 
				
			||||||
  komga,
 | 
					  komga,
 | 
				
			||||||
  kopia,
 | 
					  kopia,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user