diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 6fe1f98f..eb3fd397 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -80,6 +80,11 @@ "queued": "Queued", "movies": "Movies" }, + "lidarr": { + "wanted": "Wanted", + "queued": "Queued", + "albums": "Albums" + }, "readarr": { "wanted": "Wanted", "queued": "Queued", diff --git a/src/components/services/widget.jsx b/src/components/services/widget.jsx index 9a7254ef..e9c60a67 100644 --- a/src/components/services/widget.jsx +++ b/src/components/services/widget.jsx @@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next"; import Sonarr from "./widgets/service/sonarr"; import Radarr from "./widgets/service/radarr"; +import Lidarr from "./widgets/service/lidarr"; import Readarr from "./widgets/service/readarr"; import Bazarr from "./widgets/service/bazarr"; import Ombi from "./widgets/service/ombi"; @@ -29,6 +30,7 @@ const widgetMappings = { docker: Docker, sonarr: Sonarr, radarr: Radarr, + lidarr: Lidarr, readarr: Readarr, bazarr: Bazarr, ombi: Ombi, diff --git a/src/components/services/widgets/service/lidarr.jsx b/src/components/services/widgets/service/lidarr.jsx new file mode 100644 index 00000000..2a57844a --- /dev/null +++ b/src/components/services/widgets/service/lidarr.jsx @@ -0,0 +1,41 @@ +import useSWR from "swr"; +import { useTranslation } from "react-i18next"; + +import Widget from "../widget"; +import Block from "../block"; + +import { formatApiUrl } from "utils/api-helpers"; + +export default function Lidarr({ service }) { + const { t } = useTranslation(); + + const config = service.widget; + + const { data: albumsData, error: albumsError } = useSWR(formatApiUrl(config, "album")); + const { data: wantedData, error: wantedError } = useSWR(formatApiUrl(config, "wanted/missing")); + const { data: queueData, error: queueError } = useSWR(formatApiUrl(config, "queue/status")); + + if (albumsError || wantedError || queueError) { + return ; + } + + if (!albumsData || !wantedData || !queueData) { + return ( + + + + + + ); + } + + const have = albumsData.filter((album) => album.statistics.percentOfTracks === 100); + + return ( + + + + + + ); +} diff --git a/src/pages/api/services/proxy.js b/src/pages/api/services/proxy.js index 4a18fca6..c92fab4c 100644 --- a/src/pages/api/services/proxy.js +++ b/src/pages/api/services/proxy.js @@ -12,6 +12,7 @@ const serviceProxyHandlers = { pihole: genericProxyHandler, radarr: genericProxyHandler, sonarr: genericProxyHandler, + lidarr: genericProxyHandler, readarr: genericProxyHandler, bazarr: genericProxyHandler, speedtest: genericProxyHandler, diff --git a/src/utils/api-helpers.js b/src/utils/api-helpers.js index cf0ea99a..0b18e652 100644 --- a/src/utils/api-helpers.js +++ b/src/utils/api-helpers.js @@ -14,6 +14,7 @@ const formats = { overseerr: `{url}/api/v1/{endpoint}`, ombi: `{url}/api/v1/{endpoint}`, npm: `{url}/api/{endpoint}`, + lidarr: `{url}/api/v1/{endpoint}?apikey={key}`, readarr: `{url}/api/v1/{endpoint}?apikey={key}`, bazarr: `{url}/api/{endpoint}/wanted?apikey={key}`, sabnzbd: `{url}/api/?apikey={key}&output=json&mode={endpoint}`,