refactor lidarr widget

pull/302/head
Ben Phelps 2 years ago
parent 1840e9a57a
commit a83d5132d9

@ -1,7 +1,3 @@
// const formats = {
// lidarr: `{url}/api/v1/{endpoint}?apikey={key}`,
// };
export function formatApiCall(url, args) { export function formatApiCall(url, args) {
const find = /\{.*?\}/g; const find = /\{.*?\}/g;
const replace = (match) => { const replace = (match) => {

@ -1,12 +1,11 @@
import useSWR from "swr"; import useSWR from "swr";
import { useTranslation } from "next-i18next"; import { useTranslation } from "next-i18next";
import Widget from "../widget"; import Widget from "components/services/widgets/widget";
import Block from "../block"; import Block from "components/services/widgets/block";
import { formatProxyUrl } from "utils/api-helpers"; import { formatProxyUrl } from "utils/api-helpers";
export default function Lidarr({ service }) { export default function Component({ service }) {
const { t } = useTranslation(); const { t } = useTranslation();
const config = service.widget; const config = service.widget;

@ -0,0 +1,24 @@
import genericProxyHandler from "utils/proxies/generic";
import { jsonArrayFilter } from "utils/api-helpers";
const widget = {
api: "{url}/api/v1/{endpoint}?apikey={key}",
proxyHandler: genericProxyHandler,
mappings: {
album: {
endpoint: "album",
map: (data) => ({
have: jsonArrayFilter(data, (item) => item?.statistics?.percentOfTracks === 100).length,
}),
},
"wanted/missing": {
endpoint: "wanted/missing",
},
"queue/status": {
endpoint: "queue/status",
},
},
};
export default widget;
Loading…
Cancel
Save