random fixes (#11)
This commit is contained in:
@@ -55,7 +55,7 @@ app.get<{ Params: { "*": string } }>(
|
||||
urls.push(urls.at(-1)?.slice(0, -4) as string);
|
||||
}
|
||||
|
||||
urls = urls.map((url) => decodeURIComponent(url));
|
||||
urls = urls.map((url) => decodeURIComponent(url)).map((url) => url.replaceAll('\uFFFD', ''));
|
||||
|
||||
const result = await Promise.allSettled(
|
||||
urls.map((url) => fetch(url).then((res) => res.arrayBuffer()))
|
||||
@@ -72,11 +72,11 @@ app.get<{ Params: { "*": string } }>(
|
||||
|
||||
const video = await tsToMpeg4(buffers);
|
||||
|
||||
const fileName = `video-${new Date().toUTCString()}.mp4`;
|
||||
// const fileName = `video-${new Date().toUTCString()}.mp4`;
|
||||
|
||||
res.header("Content-Type", "video/mp4");
|
||||
res.header("Cache-Control", "public, max-age=604800");
|
||||
res.header("Content-Disposition", `attachment; filename=${fileName}`);
|
||||
// res.header("Content-Disposition", `attachment; filename=${fileName}`);
|
||||
res.send(video);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./dist",
|
||||
"lib": ["ESNext"]
|
||||
},
|
||||
"include": ["./src/**/*.ts"],
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ const Video = ({
|
||||
// Discord can't handle query params in the URL, so i have to do this 🔥beautiful mess🔥
|
||||
const url = `${apiUrl}generate/${btoa(join(streamInfo.uri, ";"))}.mp4`;
|
||||
|
||||
console.log(url);
|
||||
|
||||
return (
|
||||
<>
|
||||
<meta property="twitter:card" content="player" />
|
||||
@@ -113,8 +111,6 @@ export const Post = ({
|
||||
const isAuthor = images === post.author.avatar;
|
||||
const description = parseEmbedDescription(post);
|
||||
|
||||
console.log(post);
|
||||
|
||||
return (
|
||||
<Layout url={url}>
|
||||
<meta name="twitter:creator" content={`@${post.author.handle}`} />
|
||||
|
||||
@@ -13,7 +13,9 @@ app.use("*", async (c, next) => {
|
||||
const agent = new BskyAgent({
|
||||
service: c.env.BSKY_SERVICE_URL,
|
||||
async persistSession(_, session) {
|
||||
if (session) {
|
||||
return c.env.bskyx.put("session", JSON.stringify(session));
|
||||
}
|
||||
},
|
||||
});
|
||||
try {
|
||||
|
||||
@@ -15,8 +15,19 @@ export interface M3U8Data {
|
||||
streams: StreamInfo[];
|
||||
}
|
||||
|
||||
export async function processVideoEmbed(post: AppBskyFeedDefs.PostView) {
|
||||
const videoUrl = post.embed?.playlist as string | undefined;
|
||||
export interface VideoMedia {
|
||||
$type: `app.bsky.embed.video${string}`;
|
||||
cid: string;
|
||||
playlist: string;
|
||||
thumbnail: string;
|
||||
aspectRatio: {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
}
|
||||
|
||||
export async function processVideoEmbed(source?: VideoMedia | undefined) {
|
||||
const videoUrl = source?.playlist as string | undefined;
|
||||
|
||||
if (!videoUrl) {
|
||||
return;
|
||||
|
||||
@@ -10,3 +10,6 @@ export const concatQueryParams = (params: Record<string, string | string[]>) =>
|
||||
|
||||
export const join = (t: string | string[], s: string) =>
|
||||
Array.isArray(t) ? t.join(s) : t;
|
||||
|
||||
export const checkType = (t: string, o: any) =>
|
||||
(typeof o.$type === "string" && o.$type.startsWith(t)) || o.$type === t;
|
||||
|
||||
@@ -10,8 +10,6 @@ export const getOEmbed: Handler<Env, "/oembed"> = async (c) => {
|
||||
const type = +(c.req.query("type") ?? 0);
|
||||
const avatar = c.req.query("avatar");
|
||||
|
||||
console.log(type);
|
||||
|
||||
const defaults = {
|
||||
provider_name: "VixBluesky",
|
||||
provider_url: "https://bskyx.app/",
|
||||
|
||||
@@ -2,7 +2,8 @@ import { Handler } from "hono";
|
||||
import { HTTPException } from "hono/http-exception";
|
||||
import { fetchPost } from "../lib/fetchPostData";
|
||||
import { Post } from "../components/Post";
|
||||
import { processVideoEmbed, StreamInfo } from "../lib/processVideoEmbed";
|
||||
import { processVideoEmbed, StreamInfo, VideoMedia } from "../lib/processVideoEmbed";
|
||||
import { checkType } from "../lib/utils";
|
||||
|
||||
export const getPost: Handler<
|
||||
Env,
|
||||
@@ -12,7 +13,6 @@ export const getPost: Handler<
|
||||
const agent = c.get("Agent");
|
||||
const { data, success } = await fetchPost(agent, { user, post });
|
||||
|
||||
console.log(data);
|
||||
if (!success) {
|
||||
throw new HTTPException(500, {
|
||||
message: "Failed to fetch the post!",
|
||||
@@ -24,10 +24,11 @@ export const getPost: Handler<
|
||||
let videoMetaData: StreamInfo[] | undefined;
|
||||
|
||||
if (
|
||||
typeof fetchedPost.embed?.$type === "string" &&
|
||||
fetchedPost.embed?.$type.startsWith("app.bsky.embed.video")
|
||||
checkType("app.bsky.embed.video", fetchedPost.embed) ||
|
||||
checkType("app.bsky.embed.video", fetchedPost.embed?.media)
|
||||
) {
|
||||
videoMetaData = await processVideoEmbed(fetchedPost);
|
||||
// @ts-expect-error
|
||||
videoMetaData = await processVideoEmbed(fetchedPost.embed?.media || fetchedPost.embed);
|
||||
}
|
||||
|
||||
return c.html(
|
||||
|
||||
Reference in New Issue
Block a user