From 6aeabc690f603a08ecb771e56b65ef280f67394f Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Fri, 15 May 2026 19:11:23 +0700 Subject: [PATCH] feat: prepare media resolver source kinds Co-Authored-By: Claude Opus 4.7 --- package.json | 3 ++- pnpm-lock.yaml | 16 ++++++++++++++++ src/media/mediaTypes.ts | 2 +- src/moderation/types.ts | 2 +- tests/media/mediaResolver.test.ts | 9 +++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3ac346f..85a4994 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "db:studio": "drizzle-kit studio" }, "dependencies": { + "@dank074/discord-video-stream": "workspace:*", "@discordjs/opus": "^0.10.0", "@discordjs/voice": "^0.19.1", - "@dank074/discord-video-stream": "workspace:*", "@snazzah/davey": "^0.1.10", "@types/pg": "^8.20.0", "@vitejs/plugin-react": "^6.0.2", @@ -38,6 +38,7 @@ "pg": "^8.20.0", "pino": "^10.3.1", "pino-http": "^11.0.0", + "play-dl": "^1.9.7", "prism-media": "2.0.0-alpha.0", "prom-client": "^15.1.3", "react": "^19.2.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ae670e..379933b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,6 +59,9 @@ importers: pino-http: specifier: ^11.0.0 version: 11.0.0 + play-dl: + specifier: ^1.9.7 + version: 1.9.7 prism-media: specifier: 2.0.0-alpha.0 version: 2.0.0-alpha.0 @@ -3364,6 +3367,13 @@ packages: pkg-types@1.3.1: resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==} + play-audio@0.5.2: + resolution: {integrity: sha512-ZAqHUKkQLix2Iga7pPbsf1LpUoBjcpwU93F1l3qBIfxYddQLhxS6GKmS0d3jV8kSVaUbr6NnOEcEMFvuX93SWQ==} + + play-dl@1.9.7: + resolution: {integrity: sha512-KpgerWxUCY4s9Mhze2qdqPhiqd8Ve6HufpH9mBH3FN+vux55qSh6WJKDabfie8IBHN7lnrAlYcT/UdGax58c2A==} + engines: {node: '>=16.0.0'} + plur@4.0.0: resolution: {integrity: sha512-4UGewrYgqDFw9vV6zNV+ADmPAUAfJPKtGvb/VdpQAx25X5f3xXdGdyOEVFwkl8Hl/tl7+xbeHqSEM+D5/TirUg==} engines: {node: '>=10'} @@ -7293,6 +7303,12 @@ snapshots: mlly: 1.8.2 pathe: 2.0.3 + play-audio@0.5.2: {} + + play-dl@1.9.7: + dependencies: + play-audio: 0.5.2 + plur@4.0.0: dependencies: irregular-plurals: 3.5.0 diff --git a/src/media/mediaTypes.ts b/src/media/mediaTypes.ts index c9ce5e5..eb6464e 100644 --- a/src/media/mediaTypes.ts +++ b/src/media/mediaTypes.ts @@ -1,7 +1,7 @@ import type { Readable } from "node:stream"; export type MediaMode = "music" | "screen"; -export type MediaSourceKind = "url" | "local"; +export type MediaSourceKind = "url" | "local" | "youtube" | "spotify" | "search"; export type MediaQueueItemStatus = "queued" | "playing" | "failed"; export interface ResolvedMediaSource { diff --git a/src/moderation/types.ts b/src/moderation/types.ts index a6a6cbd..de3a275 100644 --- a/src/moderation/types.ts +++ b/src/moderation/types.ts @@ -93,7 +93,7 @@ export interface AnalysisResult { } export type MediaMode = "music" | "screen"; -export type MediaSourceKind = "url" | "local"; +export type MediaSourceKind = "url" | "local" | "youtube" | "spotify" | "search"; export type MediaQueueItemStatus = "queued" | "playing" | "failed"; export interface MediaQueueItem { diff --git a/tests/media/mediaResolver.test.ts b/tests/media/mediaResolver.test.ts index 30d341c..bbbed4b 100644 --- a/tests/media/mediaResolver.test.ts +++ b/tests/media/mediaResolver.test.ts @@ -68,4 +68,13 @@ describe("resolveMediaSource", () => { statusCode: 400, } satisfies Partial); }); + + it("keeps direct URLs as generic URL sources", async () => { + await expect( + resolveMediaSource("https://cdn.example.com/song.mp3"), + ).resolves.toMatchObject({ + kind: "url", + source: "https://cdn.example.com/song.mp3", + }); + }); });