lovely. got a couple of partial implementations....
update git ignore kaas remove large file syncy sync
This commit is contained in:
parent
89f526e9d9
commit
98cd4d630c
24 changed files with 586 additions and 76 deletions
|
@ -1,5 +1,5 @@
|
|||
|
||||
import { Meta } from "@solidjs/meta";
|
||||
import { query, createAsync, action } from "@solidjs/router";
|
||||
import { createEffect, on, ParentProps } from "solid-js";
|
||||
import { Shell } from "~/features/shell";
|
||||
import { useTheme } from "~/features/theme";
|
||||
|
@ -7,13 +7,20 @@ import { useTheme } from "~/features/theme";
|
|||
export default function ShellPage(props: ParentProps) {
|
||||
const themeContext = useTheme();
|
||||
|
||||
createEffect(on(() => themeContext.theme.colorScheme, (colorScheme) => {
|
||||
document.documentElement.dataset.theme = colorScheme;
|
||||
}));
|
||||
createEffect(
|
||||
on(
|
||||
() => themeContext.theme.colorScheme,
|
||||
(colorScheme) => {
|
||||
document.documentElement.dataset.theme = colorScheme;
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return <Shell>
|
||||
<Meta name="color-scheme" content={themeContext.theme.colorScheme} />
|
||||
return (
|
||||
<Shell>
|
||||
<Meta name="color-scheme" content={themeContext.theme.colorScheme} />
|
||||
|
||||
{props.children}
|
||||
</Shell>;
|
||||
{props.children}
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
import { json, Params, query, redirect, RouteDefinition, useParams } from "@solidjs/router";
|
||||
import {
|
||||
json,
|
||||
Params,
|
||||
query,
|
||||
redirect,
|
||||
RouteDefinition,
|
||||
useParams,
|
||||
} from "@solidjs/router";
|
||||
import { createSlug, getEntry } from "~/features/content";
|
||||
import { Player } from "~/features/player";
|
||||
import { toSlug } from "~/utilities";
|
||||
|
||||
const healUrl = query(async (slug: string) => {
|
||||
const entry = await getEntry(slug.slice(slug.lastIndexOf('-') + 1));
|
||||
const entry = await getEntry(slug.slice(slug.lastIndexOf("-") + 1));
|
||||
|
||||
if (entry === undefined) {
|
||||
return json(null, { status: 404 });
|
||||
|
@ -17,11 +24,10 @@ const healUrl = query(async (slug: string) => {
|
|||
}
|
||||
|
||||
throw redirect(`/watch/${actualSlug}`);
|
||||
}, 'watch.heal');
|
||||
}, "watch.heal");
|
||||
|
||||
interface ItemParams extends Params {
|
||||
title: string;
|
||||
id: string;
|
||||
slug: string;
|
||||
}
|
||||
|
||||
export const route = {
|
||||
|
@ -31,11 +37,12 @@ export const route = {
|
|||
} satisfies RouteDefinition;
|
||||
|
||||
export default function Item() {
|
||||
const params = useParams<ItemParams>();
|
||||
const { slug } = useParams<ItemParams>();
|
||||
const id = slug.slice(slug.lastIndexOf("-") + 1);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Player id={params.id} />
|
||||
<Player id={id} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
4
src/routes/api/auth/[...action].ts
Normal file
4
src/routes/api/auth/[...action].ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { auth } from "~/auth";
|
||||
import { toSolidStartHandler } from "better-auth/solid-start";
|
||||
|
||||
export const { GET, POST } = toSolidStartHandler(auth);
|
BIN
src/routes/api/content/SampleVideo_1280x720_10mb.mp4
Normal file
BIN
src/routes/api/content/SampleVideo_1280x720_10mb.mp4
Normal file
Binary file not shown.
16
src/routes/api/content/metadata.ts
Normal file
16
src/routes/api/content/metadata.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { json } from "@solidjs/router";
|
||||
import { APIEvent } from "@solidjs/start/server";
|
||||
|
||||
export const GET = async (event: APIEvent) => {
|
||||
console.log(event.params);
|
||||
|
||||
const path = `${import.meta.dirname}/SampleVideo_1280x720_10mb`;
|
||||
|
||||
return json({
|
||||
captions: await Bun.file(`${path}.captions.vtt`).bytes(),
|
||||
thumbnails: {
|
||||
track: await Bun.file(`${path}.thumbnails.vtt`).text(),
|
||||
image: await Bun.file(`${import.meta.dirname}/overview.jpg`).bytes(),
|
||||
},
|
||||
});
|
||||
};
|
45
src/routes/api/content/stream.ts
Normal file
45
src/routes/api/content/stream.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { APIEvent } from "@solidjs/start/server";
|
||||
|
||||
const CHUNK_SIZE = 1 * 1e6; // 1MB
|
||||
|
||||
export const GET = async ({ request, ...event }: APIEvent) => {
|
||||
"use server";
|
||||
|
||||
const range = request.headers.get("range");
|
||||
|
||||
if (range === null) {
|
||||
return new Response("Requires Range header", { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const file = Bun.file(
|
||||
import.meta.dirname + "/SampleVideo_1280x720_10mb.mp4",
|
||||
);
|
||||
|
||||
if ((await file.exists()) !== true) {
|
||||
return new Response("File not found", { status: 404 });
|
||||
}
|
||||
|
||||
const videoSize = file.size;
|
||||
|
||||
const start = Number.parseInt(range.replace(/\D/g, ""));
|
||||
const end = Math.min(start + CHUNK_SIZE, videoSize - 1);
|
||||
const contentLength = end - start + 1;
|
||||
|
||||
return new Response(file.stream());
|
||||
|
||||
// return new Response(video.slice(start, end).stream(), {
|
||||
// status: 206,
|
||||
// headers: {
|
||||
// 'Accept-Ranges': 'bytes',
|
||||
// 'Content-Range': `bytes ${start}-${end}/${videoSize}`,
|
||||
// 'Content-Length': `${contentLength}`,
|
||||
// 'Content-type': 'video/mp4',
|
||||
// },
|
||||
// });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue