From b4405c525ab78f1bc7e17f585b7fe703350bfb32 Mon Sep 17 00:00:00 2001 From: GodD6366 Date: Wed, 10 Apr 2024 12:33:52 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=20moviebot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widgets/components.js | 1 + src/widgets/moviebot/component.jsx | 44 ++++++++++++++++++++++++++++++ src/widgets/moviebot/widget.js | 27 ++++++++++++++++++ src/widgets/widgets.js | 2 ++ 4 files changed, 74 insertions(+) create mode 100644 src/widgets/moviebot/component.jsx create mode 100644 src/widgets/moviebot/widget.js diff --git a/src/widgets/components.js b/src/widgets/components.js index 500fe0ce..4a401122 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -61,6 +61,7 @@ const components = { mikrotik: dynamic(() => import("./mikrotik/component")), mjpeg: dynamic(() => import("./mjpeg/component")), moonraker: dynamic(() => import("./moonraker/component")), + moviebot: dynamic(() => import("./moviebot/component")), mylar: dynamic(() => import("./mylar/component")), navidrome: dynamic(() => import("./navidrome/component")), netalertx: dynamic(() => import("./netalertx/component")), diff --git a/src/widgets/moviebot/component.jsx b/src/widgets/moviebot/component.jsx new file mode 100644 index 00000000..429d6e0f --- /dev/null +++ b/src/widgets/moviebot/component.jsx @@ -0,0 +1,44 @@ +import { useTranslation } from "next-i18next"; + +import Block from "components/services/widget/block"; +import Container from "components/services/widget/container"; +import useWidgetAPI from "utils/proxy/use-widget-api"; + +export default function Component({ service }) { + const { t } = useTranslation(); + + const { widget } = service; + + const { data: listTVResult } = useWidgetAPI(widget, "SubscribeList", { + refreshInterval: 60000, + media_type: "TV", + }); + const { data: listMovieResult } = useWidgetAPI(widget, "SubscribeList", { + refreshInterval: 60000, + media_type: "Movie", + }); + + let subingTVList = []; + let subingMovieList = []; + if (listTVResult && listMovieResult) { + subingTVList = listTVResult.data.filter((item) => item.status === 0); + subingMovieList = listMovieResult.data.filter((item) => item.status === 0); + } + + const result = useWidgetAPI(widget, "GetSites", { + refreshInterval: 60000, + }); + const sites = result.data?.data || []; + + return ( + + + + s.status === 1).length })} /> + s.status === 0).length })} + /> + + ); +} diff --git a/src/widgets/moviebot/widget.js b/src/widgets/moviebot/widget.js new file mode 100644 index 00000000..7f965197 --- /dev/null +++ b/src/widgets/moviebot/widget.js @@ -0,0 +1,27 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/{endpoint}&access_key={key}", + proxyHandler: genericProxyHandler, + + mappings: { + SubscribeList: { + headers: { + "User-Agent": "Mozilla/5.0", // Crowdsec requires a user-agent + "Content-Type": "application/json", + }, + endpoint: "api/subscribe/list", + params: ["media_type"], + }, + GetSites: { + headers: { + "User-Agent": "Mozilla/5.0", // Crowdsec requires a user-agent + "Content-Type": "application/json", + }, + endpoint: "api/site/get_sites", + params: ["refreshInterval"], + }, + }, +}; + +export default widget; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 7ed98bfb..1745532d 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -53,6 +53,7 @@ import miniflux from "./miniflux/widget"; import mikrotik from "./mikrotik/widget"; import mjpeg from "./mjpeg/widget"; import moonraker from "./moonraker/widget"; +import moviebot from "./moviebot/widget"; import mylar from "./mylar/widget"; import navidrome from "./navidrome/widget"; import netalertx from "./netalertx/widget"; @@ -169,6 +170,7 @@ const widgets = { mikrotik, mjpeg, moonraker, + moviebot, mylar, navidrome, netalertx,