mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Feature: add navidrome support
This commit is contained in:
parent
2ab05350a3
commit
210d746ef6
@ -168,6 +168,12 @@
|
|||||||
"services": "Services",
|
"services": "Services",
|
||||||
"middleware": "Middleware"
|
"middleware": "Middleware"
|
||||||
},
|
},
|
||||||
|
"navidrome": {
|
||||||
|
"user": "User",
|
||||||
|
"artist": "Artist",
|
||||||
|
"song": "Song",
|
||||||
|
"album": "Album"
|
||||||
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
"disabled": "Disabled",
|
"disabled": "Disabled",
|
||||||
|
@ -16,6 +16,7 @@ const components = {
|
|||||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||||
lidarr: dynamic(() => import("./lidarr/component")),
|
lidarr: dynamic(() => import("./lidarr/component")),
|
||||||
mastodon: dynamic(() => import("./mastodon/component")),
|
mastodon: dynamic(() => import("./mastodon/component")),
|
||||||
|
navidrome: dynamic(() => import("./navidrome/component")),
|
||||||
npm: dynamic(() => import("./npm/component")),
|
npm: dynamic(() => import("./npm/component")),
|
||||||
nzbget: dynamic(() => import("./nzbget/component")),
|
nzbget: dynamic(() => import("./nzbget/component")),
|
||||||
ombi: dynamic(() => import("./ombi/component")),
|
ombi: dynamic(() => import("./ombi/component")),
|
||||||
|
45
src/widgets/navidrome/component.jsx
Normal file
45
src/widgets/navidrome/component.jsx
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
|
import Container from "components/services/widget/container";
|
||||||
|
import Block from "components/services/widget/block";
|
||||||
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
export default function Component({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { widget } = service;
|
||||||
|
|
||||||
|
const { data: navidromeData, error: navidromeError } = useWidgetAPI(widget, "getNowPlaying");
|
||||||
|
|
||||||
|
if (navidromeError) {
|
||||||
|
return <Container error={t("widget.api_error")} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!navidromeData || Object.keys(navidromeData["subsonic-response"].nowPlaying).length === 0) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="navidrome.user" />
|
||||||
|
<Block label="navidrome.artist" />
|
||||||
|
<Block label="navidrome.song" />
|
||||||
|
<Block label="navidrome.album" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const nowPlaying = Object.values(navidromeData["subsonic-response"].nowPlaying.entry);
|
||||||
|
const songList = [];
|
||||||
|
|
||||||
|
nowPlaying.forEach(userPlay => {
|
||||||
|
const playing = (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="navidrome.user" value={userPlay.username} />
|
||||||
|
<Block label="navidrome.artist" value={userPlay.artist} />
|
||||||
|
<Block label="navidrome.song" value={userPlay.title} />
|
||||||
|
<Block label="navidrome.album" value={userPlay.album} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
songList.unshift(playing);
|
||||||
|
});
|
||||||
|
|
||||||
|
return songList;
|
||||||
|
}
|
14
src/widgets/navidrome/widget.js
Normal file
14
src/widgets/navidrome/widget.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/rest/{endpoint}?u={user}&t={token}&s={salt}&v={version}&c={client}&f=json",
|
||||||
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
"getNowPlaying": {
|
||||||
|
endpoint: "getNowPlaying",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -11,6 +11,7 @@ import jackett from "./jackett/widget";
|
|||||||
import jellyseerr from "./jellyseerr/widget";
|
import jellyseerr from "./jellyseerr/widget";
|
||||||
import lidarr from "./lidarr/widget";
|
import lidarr from "./lidarr/widget";
|
||||||
import mastodon from "./mastodon/widget";
|
import mastodon from "./mastodon/widget";
|
||||||
|
import navidrome from "./navidrome/widget";
|
||||||
import npm from "./npm/widget";
|
import npm from "./npm/widget";
|
||||||
import nzbget from "./nzbget/widget";
|
import nzbget from "./nzbget/widget";
|
||||||
import ombi from "./ombi/widget";
|
import ombi from "./ombi/widget";
|
||||||
@ -51,6 +52,7 @@ const widgets = {
|
|||||||
jellyseerr,
|
jellyseerr,
|
||||||
lidarr,
|
lidarr,
|
||||||
mastodon,
|
mastodon,
|
||||||
|
navidrome,
|
||||||
npm,
|
npm,
|
||||||
nzbget,
|
nzbget,
|
||||||
ombi,
|
ombi,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user