feat: add tubearchivist widget

pull/471/head
Brandon Barker 2 years ago
parent 49a764e864
commit 68b8e4b376

@ -303,5 +303,11 @@
"rejectedPushes": "Rejected",
"filters": "Filters",
"indexers": "Indexers"
},
"tubearchivist": {
"downloads": "Queue",
"videos": "Videos",
"channels": "Channels",
"playlists": "Playlists"
}
}

@ -33,6 +33,8 @@ export default async function credentialedProxyHandler(req, res) {
headers.Authorization = `PVEAPIToken=${widget.username}=${widget.password}`;
} else if (widget.type === "autobrr") {
headers["X-API-Token"] = `${widget.key}`;
} else if (widget.type === "tubearchivist") {
headers.Authorization = `Token ${widget.key}`;
} else {
headers["X-API-Key"] = `${widget.key}`;
}

@ -36,6 +36,7 @@ const components = {
tautulli: dynamic(() => import("./tautulli/component")),
traefik: dynamic(() => import("./traefik/component")),
transmission: dynamic(() => import("./transmission/component")),
tubearchivist: dynamic(() => import("./tubearchivist/component")),
unifi: dynamic(() => import("./unifi/component")),
watchtower: dynamic(() => import("./watchtower/component")),
};

@ -0,0 +1,40 @@
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: downloadsData, error: downloadsError } = useWidgetAPI(widget, "downloads");
const { data: videosData, error: videosError } = useWidgetAPI(widget, "videos");
const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "channels");
const { data: playlistsData, error: playlistsError } = useWidgetAPI(widget, "playlists");
if (downloadsError || videosError || channelsError || playlistsError) {
return <Container error={t("widget.api_error")} />;
}
if (!downloadsData || !videosData || !channelsData || !playlistsData) {
return (
<Container service={service}>
<Block label="tubearchivist.downloads" />
<Block label="tubearchivist.videos" />
<Block label="tubearchivist.channels" />
<Block label="tubearchivist.playlists" />
</Container>
);
}
return (
<Container service={service}>
<Block label="tubearchivist.downloads" value={t("common.number", { value: downloadsData?.paginate?.total_hits })} />
<Block label="tubearchivist.videos" value={t("common.number", { value: videosData?.paginate?.total_hits })} />
<Block label="tubearchivist.channels" value={t("common.number", { value: channelsData?.paginate?.total_hits })} />
<Block label="tubearchivist.playlists" value={t("common.number", { value: playlistsData?.paginate?.total_hits })} />
</Container>
);
}

@ -0,0 +1,23 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/api/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
downloads: {
endpoint: "download",
},
videos: {
endpoint: "video",
},
channels: {
endpoint: "channel",
},
playlists: {
endpoint: "playlist",
},
},
};
export default widget;

@ -31,6 +31,7 @@ import strelaysrv from "./strelaysrv/widget";
import tautulli from "./tautulli/widget";
import traefik from "./traefik/widget";
import transmission from "./transmission/widget";
import tubearchivist from "./tubearchivist/widget";
import unifi from "./unifi/widget";
import watchtower from './watchtower/widget'
@ -69,6 +70,7 @@ const widgets = {
tautulli,
traefik,
transmission,
tubearchivist,
unifi,
unifi_console: unifi,
watchtower,

Loading…
Cancel
Save