Add HDHomeRun Widget
This commit is contained in:
parent
672fc3716a
commit
cee4173077
@ -309,5 +309,9 @@
|
|||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"channels": "Channels",
|
"channels": "Channels",
|
||||||
"playlists": "Playlists"
|
"playlists": "Playlists"
|
||||||
|
},
|
||||||
|
"hdhomerun": {
|
||||||
|
"channels": "Channels",
|
||||||
|
"hd": "HD"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const components = {
|
|||||||
docker: dynamic(() => import("./docker/component")),
|
docker: dynamic(() => import("./docker/component")),
|
||||||
emby: dynamic(() => import("./emby/component")),
|
emby: dynamic(() => import("./emby/component")),
|
||||||
gotify: dynamic(() => import("./gotify/component")),
|
gotify: dynamic(() => import("./gotify/component")),
|
||||||
|
hdhomerun: dynamic(() => import("./hdhomerun/component")),
|
||||||
homebridge: dynamic(() => import("./homebridge/component")),
|
homebridge: dynamic(() => import("./homebridge/component")),
|
||||||
jackett: dynamic(() => import("./jackett/component")),
|
jackett: dynamic(() => import("./jackett/component")),
|
||||||
jellyfin: dynamic(() => import("./emby/component")),
|
jellyfin: dynamic(() => import("./emby/component")),
|
||||||
|
|||||||
34
src/widgets/hdhomerun/component.jsx
Normal file
34
src/widgets/hdhomerun/component.jsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
21
src/widgets/hdhomerun/widget.js
Normal file
21
src/widgets/hdhomerun/widget.js
Normal 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;
|
||||||
@ -6,6 +6,7 @@ import changedetectionio from "./changedetectionio/widget";
|
|||||||
import coinmarketcap from "./coinmarketcap/widget";
|
import coinmarketcap from "./coinmarketcap/widget";
|
||||||
import emby from "./emby/widget";
|
import emby from "./emby/widget";
|
||||||
import gotify from "./gotify/widget";
|
import gotify from "./gotify/widget";
|
||||||
|
import hdhomerun from "./hdhomerun/widget";
|
||||||
import homebridge from "./homebridge/widget";
|
import homebridge from "./homebridge/widget";
|
||||||
import jackett from "./jackett/widget";
|
import jackett from "./jackett/widget";
|
||||||
import jellyseerr from "./jellyseerr/widget";
|
import jellyseerr from "./jellyseerr/widget";
|
||||||
@ -44,6 +45,7 @@ const widgets = {
|
|||||||
coinmarketcap,
|
coinmarketcap,
|
||||||
emby,
|
emby,
|
||||||
gotify,
|
gotify,
|
||||||
|
hdhomerun,
|
||||||
homebridge,
|
homebridge,
|
||||||
jackett,
|
jackett,
|
||||||
jellyfin: emby,
|
jellyfin: emby,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user