Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HDHomeRun widget #484

Merged
merged 4 commits into from Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/locales/en/common.json
Expand Up @@ -334,5 +334,9 @@
"public_ip": "Public IP",
"region": "Region",
"country": "Country"
},
"hdhomerun": {
"channels": "Channels",
"hd": "HD"
}
}
1 change: 1 addition & 0 deletions src/widgets/components.js
Expand Up @@ -11,6 +11,7 @@ const components = {
emby: dynamic(() => import("./emby/component")),
gluetun: dynamic(() => import("./gluetun/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")),
Expand Down
36 changes: 36 additions & 0 deletions src/widgets/hdhomerun/component.jsx
@@ -0,0 +1,36 @@
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");

if (channelsError) {
return <Container error={channelsError} />;
}

if (!channelsData) {
return (
<Container service={service}>
<Block label="hdhomerun.channels" />
<Block label="hdhomerun.hd" />
</Container>
);
}

const hdChannels = channelsData?.filter((channel) => channel.HD === 1);

return (
<Container service={service}>
<Block label="hdhomerun.channels" value={channelsData.length } />
<Block label="hdhomerun.hd" value={hdChannels.length} />

</Container>
);
}
14 changes: 14 additions & 0 deletions src/widgets/hdhomerun/widget.js
@@ -0,0 +1,14 @@
import genericProxyHandler from "utils/proxy/handlers/generic";

const widget = {
api: "{url}/{endpoint}",
proxyHandler: genericProxyHandler,

mappings: {
"lineup": {
endpoint: "lineup.json",
}
},
};

export default widget;
2 changes: 2 additions & 0 deletions src/widgets/widgets.js
Expand Up @@ -7,6 +7,7 @@ import coinmarketcap from "./coinmarketcap/widget";
import emby from "./emby/widget";
import gluetun from "./gluetun/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";
Expand Down Expand Up @@ -49,6 +50,7 @@ const widgets = {
emby,
gluetun,
gotify,
hdhomerun,
homebridge,
jackett,
jellyfin: emby,
Expand Down