Add HDHomeRun Widget

This commit is contained in:
Don Reece 2022-11-03 21:17:27 -04:00
parent 672fc3716a
commit cee4173077
5 changed files with 62 additions and 0 deletions

View File

@ -309,5 +309,9 @@
"videos": "Videos",
"channels": "Channels",
"playlists": "Playlists"
},
"hdhomerun": {
"channels": "Channels",
"hd": "HD"
}
}

View File

@ -10,6 +10,7 @@ const components = {
docker: dynamic(() => import("./docker/component")),
emby: dynamic(() => import("./emby/component")),
gotify: dynamic(() => import("./gotify/component")),
hdhomerun: dynamic(() => import("./hdhomerun/component")),
homebridge: dynamic(() => import("./homebridge/component")),
jackett: dynamic(() => import("./jackett/component")),
jellyfin: dynamic(() => import("./emby/component")),

View File

@ -0,0 +1,34 @@
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: channelsData, error: channelsError } = useWidgetAPI(widget, "lineup.json");
const { data: hdData, error: hdError } = useWidgetAPI(widget, "hd");
if (channelsError || hdError) {
return <Container error={t("widget.api_error")} />;
}
if (!channelsData || !hdData) {
return (
<Container service={service}>
<Block label="hdhomerun.channels" />
<Block label="hdhomerun.hd" />
</Container>
);
}
return (
<Container service={service}>
<Block label="hdhomerun.channels" value={t("common.number", { value: channelsData.length })} />
<Block label="hdhomerun.hd" value={t("common.number", { value: hdData.have })} />
</Container>
);
}

View File

@ -0,0 +1,21 @@
import genericProxyHandler from "utils/proxy/handlers/generic";
import { jsonArrayFilter } from "utils/proxy/api-helpers";
const widget = {
api: "{url}/{endpoint}",
proxyHandler: genericProxyHandler,
mappings: {
"lineup.json": {
endpoint: "lineup.json",
},
hd: {
endpoint: "lineup.json",
map: (data) => ({
have: jsonArrayFilter(data, (item) => item?.HD === 1).length,
}),
},
},
};
export default widget;

View File

@ -6,6 +6,7 @@ import changedetectionio from "./changedetectionio/widget";
import coinmarketcap from "./coinmarketcap/widget";
import emby from "./emby/widget";
import gotify from "./gotify/widget";
import hdhomerun from "./hdhomerun/widget";
import homebridge from "./homebridge/widget";
import jackett from "./jackett/widget";
import jellyseerr from "./jellyseerr/widget";
@ -44,6 +45,7 @@ const widgets = {
coinmarketcap,
emby,
gotify,
hdhomerun,
homebridge,
jackett,
jellyfin: emby,