diff --git a/api/src/controllers/video-metadata.ts b/api/src/controllers/video-metadata.ts
index 53ebb5ae..cd16d007 100644
--- a/api/src/controllers/video-metadata.ts
+++ b/api/src/controllers/video-metadata.ts
@@ -194,8 +194,9 @@ export const videosMetadata = new Elysia({
)
.get(
":id/prepare",
- async ({ params: { id }, headers: { authorization } }) => {
- await prepareVideo(id, authorization!);
+ async ({ params: { id }, headers: { authorization }, status }) => {
+ const ret = await prepareVideo(id, authorization!);
+ if (ret) return status(ret.status, ret);
},
{
detail: { description: "Prepare a video for playback" },
@@ -219,7 +220,6 @@ export const videosMetadata = new Elysia({
);
export const prepareVideo = async (slug: string, auth: string) => {
- logger.info("Preparing next video {slug}", { slug });
const [vid] = await db
.select({ path: videos.path, show: entries.showPk, order: entries.order })
.from(videos)
@@ -228,6 +228,13 @@ export const prepareVideo = async (slug: string, auth: string) => {
.where(eq(entryVideoJoin.slug, slug))
.limit(1);
+ if (!vid) {
+ return {
+ status: 404,
+ message: `No video found with slug ${slug}`,
+ } as const;
+ }
+
const related = vid.show
? await db
.select({ order: entries.order, path: videos.path })
@@ -238,6 +245,14 @@ export const prepareVideo = async (slug: string, auth: string) => {
.orderBy(entries.order)
: [];
const idx = related.findIndex((x) => x.order === vid.order);
+ const near = [related[idx - 1], related[idx + 1]]
+ .filter((x) => x)
+ .map((x) => x.path);
+
+ logger.info("Preparing next video {slug} (near episodes: {near})", {
+ slug,
+ near,
+ });
const path = Buffer.from(vid.path, "utf8").toString("base64url");
await fetch(
@@ -252,9 +267,7 @@ export const prepareVideo = async (slug: string, auth: string) => {
},
method: "POST",
body: JSON.stringify({
- nearEpisodes: [related[idx - 1], related[idx + 1]]
- .filter((x) => x)
- .map((x) => x.path),
+ nearEpisodes: near,
}),
},
);
diff --git a/front/src/ui/player/controls/index.tsx b/front/src/ui/player/controls/index.tsx
index a93d3ba3..5cb67d38 100644
--- a/front/src/ui/player/controls/index.tsx
+++ b/front/src/ui/player/controls/index.tsx
@@ -97,7 +97,7 @@ export const Controls = ({
);
diff --git a/front/src/ui/player/controls/skip-chapter.tsx b/front/src/ui/player/controls/skip-chapter.tsx
index c2417eb6..8c133ba7 100644
--- a/front/src/ui/player/controls/skip-chapter.tsx
+++ b/front/src/ui/player/controls/skip-chapter.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { useEvent, type VideoPlayer } from "react-native-video";
import type { Chapter } from "~/models";
import { Button } from "~/primitives";
+import { cn } from "~/utils";
export const SkipChapterButton = ({
player,
@@ -32,7 +33,10 @@ export const SkipChapterButton = ({