tuberepair/src/api/feed.ts
2025-12-23 02:14:20 +02:00

25 lines
730 B
TypeScript

import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import innertube from "../lib/innertube.js";
import homeFeed from "../templates/homeFeed.js";
import { FeedGetSchema } from "../models/FeedGetSchema.js";
import { parseHomeFeed } from "../lib/utils/feed.js";
import type { YT } from "youtubei.js";
const feed = new Hono();
feed.get(
"/standardfeeds/:region/:type",
zValidator("param", FeedGetSchema),
async (c) => {
const { type } = c.req.valid("param");
if (type != "most_popular") return c.html(homeFeed())
const data = await innertube.getHomeFeed();
const feed = data as YT.HomeFeed;
return c.html(homeFeed(await parseHomeFeed(feed)))
}
)
export default feed