Skip to content

Commit

Permalink
feat: #655 implement jellyfin media server
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Jun 10, 2024
1 parent 9cab001 commit 13f56de
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
"typescript.tsdk": "node_modules\\typescript\\lib",
"js/ts.implicitProjectConfig.experimentalDecorators": true,
"prettier.configPath": "./tooling/prettier/index.mjs",
"cSpell.words": ["cqmin", "homarr", "superjson", "trpc", "Umami"],
"cSpell.words": [
"cqmin",
"homarr",
"jellyfin",
"superjson",
"trpc",
"Umami"
],
"i18n-ally.dirStructure": "auto",
"i18n-ally.enabledFrameworks": ["next-international"],
"i18n-ally.localesPaths": ["./packages/translation/src/lang/"],
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/router/widgets/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createTRPCRouter } from "../../trpc";
import { appRouter } from "./app";
import { dnsHoleRouter } from "./dns-hole";
import { mediaServerRouter } from "./media-server";
import { notebookRouter } from "./notebook";
import { smartHomeRouter } from "./smart-home";
import { weatherRouter } from "./weather";
Expand All @@ -11,4 +12,5 @@ export const widgetRouter = createTRPCRouter({
app: appRouter,
dnsHole: dnsHoleRouter,
smartHome: smartHomeRouter,
mediaServer: mediaServerRouter
});
15 changes: 15 additions & 0 deletions packages/api/src/router/widgets/media-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createCacheChannel } from "@homarr/redis";
import { z } from "@homarr/validation";

import { createManyIntegrationMiddleware } from "../../middlewares/integration";
import { createTRPCRouter, publicProcedure } from "../../trpc";

export const mediaServerRouter = createTRPCRouter({
getCurrentStreams: publicProcedure
.unstable_concat(createManyIntegrationMiddleware("jellyfin", "plex"))
.query(async ({ ctx, input }) => {
const cache = createCacheChannel("media-server");
await cache.consumeAsync(async () => {});
return {};
}),
});
1 change: 1 addition & 0 deletions packages/definitions/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export const widgetKinds = [
"dnsHoleSummary",
"smartHome-entityState",
"smartHome-executeAutomation",
"mediaServer"
] as const;
export type WidgetKind = (typeof widgetKinds)[number];
2 changes: 2 additions & 0 deletions packages/widgets/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { WidgetImportRecord } from "./import";
import * as notebook from "./notebook";
import * as smartHomeEntityState from "./smart-home/entity-state";
import * as smartHomeExecuteAutomation from "./smart-home/execute-automation";
import * as mediaServer from "./media-server";
import * as video from "./video";
import * as weather from "./weather";

Expand All @@ -33,6 +34,7 @@ export const widgetImports = {
dnsHoleSummary,
"smartHome-entityState": smartHomeEntityState,
"smartHome-executeAutomation": smartHomeExecuteAutomation,
mediaServer
} satisfies WidgetImportRecord;

export type WidgetImports = typeof widgetImports;
Expand Down
5 changes: 5 additions & 0 deletions packages/widgets/src/media-server/component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WidgetComponentProps } from "../definition";

export default function MediaServerWidget({ options }: WidgetComponentProps<"mediaServer">) {
return <span>TEST!!</span>
}
11 changes: 11 additions & 0 deletions packages/widgets/src/media-server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IconVideo } from "@tabler/icons-react";

import { createWidgetDefinition } from "../definition";

export const { componentLoader, definition } = createWidgetDefinition("mediaServer", {
icon: IconVideo,
options: {},
supportedIntegrations: ["jellyfin", "plex"],
})
.withServerData(() => import("./serverData"))
.withDynamicImport(() => import("./component"));
12 changes: 12 additions & 0 deletions packages/widgets/src/media-server/serverData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use server";

import { api } from "@homarr/api/server";
import type { WidgetProps } from "../definition";

export default async function getServerDataAsync({ integrationIds }: WidgetProps<"mediaServer">) {
const currentStreams = await api.widget.mediaServer.getCurrentStreams({
integrationIds
});

return currentStreams;
}

0 comments on commit 13f56de

Please sign in to comment.