diff --git a/src/components/services/widgets/service/lidarr.jsx b/src/components/services/widgets/service/lidarr.jsx index 17689a572..8818b7c11 100644 --- a/src/components/services/widgets/service/lidarr.jsx +++ b/src/components/services/widgets/service/lidarr.jsx @@ -29,13 +29,11 @@ export default function Lidarr({ service }) { ); } - const have = albumsData.filter((album) => album.statistics.percentOfTracks === 100); - return ( - + ); } diff --git a/src/components/services/widgets/service/radarr.jsx b/src/components/services/widgets/service/radarr.jsx index 125f0f94a..6a4401d3d 100644 --- a/src/components/services/widgets/service/radarr.jsx +++ b/src/components/services/widgets/service/radarr.jsx @@ -28,14 +28,11 @@ export default function Radarr({ service }) { ); } - const wanted = moviesData.filter((movie) => movie.isAvailable === false); - const have = moviesData.filter((movie) => movie.isAvailable === true); - return ( - + - + ); } diff --git a/src/components/services/widgets/service/readarr.jsx b/src/components/services/widgets/service/readarr.jsx index 2117cde8f..c1ddea31e 100644 --- a/src/components/services/widgets/service/readarr.jsx +++ b/src/components/services/widgets/service/readarr.jsx @@ -29,13 +29,11 @@ export default function Readarr({ service }) { ); } - const have = booksData.filter((book) => book.statistics.bookFileCount > 0); - return ( - + ); } diff --git a/src/components/services/widgets/service/sonarr.jsx b/src/components/services/widgets/service/sonarr.jsx index a269bb5c1..f95def973 100644 --- a/src/components/services/widgets/service/sonarr.jsx +++ b/src/components/services/widgets/service/sonarr.jsx @@ -33,7 +33,7 @@ export default function Sonarr({ service }) { - + ); } diff --git a/src/pages/api/services/proxy.js b/src/pages/api/services/proxy.js index 364a5b7e4..bc9c9c8ec 100644 --- a/src/pages/api/services/proxy.js +++ b/src/pages/api/services/proxy.js @@ -16,16 +16,63 @@ function jsonArrayMapper(data, map) { return data; } +function asJson(data) { + if (data?.length > 0) { + const json = JSON.parse(data.toString()); + return json; + } + return data; +} + const serviceProxyHandlers = { // uses query param auth emby: genericProxyHandler, jellyfin: genericProxyHandler, pihole: genericProxyHandler, - radarr: genericProxyHandler, - sonarr: genericProxyHandler, - lidarr: genericProxyHandler, - readarr: genericProxyHandler, - bazarr: genericProxyHandler, + radarr: { + proxy: genericProxyHandler, + maps: { + movie: (data) => ({ + wanted: jsonArrayMapper(data, (item) => item.isAvailable === false).length, + have: jsonArrayMapper(data, (item) => item.isAvailable === true).length, + }), + }, + }, + sonarr: { + proxy: genericProxyHandler, + maps: { + series: (data) => ({ + total: asJson(data.toString()).length, + }), + }, + }, + lidarr: { + proxy: genericProxyHandler, + maps: { + album: (data) => ({ + have: jsonArrayMapper(data, (item) => item.statistics.percentOfTracks === 100).length, + }), + }, + }, + readarr: { + proxy: genericProxyHandler, + maps: { + book: (data) => ({ + have: jsonArrayMapper(data, (item) => item.statistics.bookFileCount > 0).length, + }), + }, + }, + bazarr: { + proxy: genericProxyHandler, + maps: { + movies: (data) => ({ + total: asJson(data.toString()).total, + }), + episodes: (data) => ({ + total: asJson(data.toString()).total, + }), + }, + }, speedtest: genericProxyHandler, tautulli: genericProxyHandler, traefik: genericProxyHandler,