diff --git a/api/src/controllers/videos.ts b/api/src/controllers/videos.ts index 60ebcc89..04bdeb0b 100644 --- a/api/src/controllers/videos.ts +++ b/api/src/controllers/videos.ts @@ -604,6 +604,49 @@ export const videosReadH = new Elysia({ prefix: "/videos", tags: ["videos"] }) }, }, ) + .get( + ":id/thumbnails.vtt", + async ({ params: { id }, status, redirect }) => { + const [video] = await db + .select({ + path: videos.path, + }) + .from(videos) + .leftJoin(entryVideoJoin, eq(videos.pk, entryVideoJoin.videoPk)) + .where(isUuid(id) ? eq(videos.id, id) : eq(entryVideoJoin.slug, id)) + .limit(1); + + if (!video) { + return status(404, { + status: 404, + message: `No video found with id or slug '${id}'`, + }); + } + const path = Buffer.from(video.path, "utf8").toString("base64url"); + return redirect(`/video/${path}/thumbnails.vtt`); + }, + { + detail: { + description: "Get redirected to the direct stream of the video", + }, + params: t.Object({ + id: t.String({ + description: "The id or slug of the video to watch.", + example: "made-in-abyss-s1e13", + }), + }), + response: { + 302: t.Void({ + description: + "Redirected to the [/video/{path}/direct](?api=transcoder#tag/metadata/get/:path/direct) route (of the transcoder)", + }), + 404: { + ...KError, + description: "No video found with the given id or slug.", + }, + }, + }, + ) .get( ":id/direct", async ({ params: { id }, status, redirect }) => { diff --git a/front/src/primitives/image-background.tsx b/front/src/primitives/image/image-background.tsx similarity index 97% rename from front/src/primitives/image-background.tsx rename to front/src/primitives/image/image-background.tsx index 2585f195..7f4ad4aa 100644 --- a/front/src/primitives/image-background.tsx +++ b/front/src/primitives/image/image-background.tsx @@ -9,7 +9,7 @@ import { withUniwind } from "uniwind"; import type { KImage } from "~/models"; import { useToken } from "~/providers/account-context"; import { cn } from "~/utils"; -import { PosterPlaceholder } from "./image"; +import { PosterPlaceholder } from "../image/image"; const ImgBg = withUniwind(EImageBackground); diff --git a/front/src/primitives/image.tsx b/front/src/primitives/image/image.tsx similarity index 98% rename from front/src/primitives/image.tsx rename to front/src/primitives/image/image.tsx index ea0eca63..c253cc33 100644 --- a/front/src/primitives/image.tsx +++ b/front/src/primitives/image/image.tsx @@ -7,7 +7,7 @@ import type { YoshikiStyle } from "yoshiki/src/type"; import type { KImage } from "~/models"; import { useToken } from "~/providers/account-context"; import { cn } from "~/utils"; -import { Skeleton } from "./skeleton"; +import { Skeleton } from "../skeleton"; export type YoshikiEnhanced