import { doodstream, format, streamwish } from "https://esm.town/v/tempguy/redMonkey";
import { Hono } from "npm:hono";
const app = new Hono();
app.get("/embed/:id/:ep/:dub", async (c) => {
const id = c.req.param("id");
const ep = Number(c.req.param("ep"));
const dub = c.req.param("dub") === "dub";
const results = [];
const metaResponse = await fetch(
`https://cool-proxy.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=https://api.malsync.moe/mal/anime/${id}`,
);
const metaData = await metaResponse.json();
const GOGO = metaData.Sites.Gogoanime;
console.log(metaData);
const watchID = Object.values(GOGO).flatMap((data) => {
const isDub = data.identifier.includes("dub");
console.log(data.identifier);
if (dub && isDub || !dub && !isDub) {
const episodeIdentifier = `${data.identifier}-episode-${ep}`;
return [
fetch(`https://animetize-api.vercel.app/servers/${episodeIdentifier}`),
fetch(`https://animetize-api.vercel.app/watch/${episodeIdentifier}`),
];
}
return [];
});
console.log(watchID);
const [baseResponse, mainResponse] = await Promise.all(watchID);
const baseData = await baseResponse.json();
const mainData = await mainResponse.json();
await Promise.all(
mainData.sources.map(async (data) => {
if (data.quality === "default" || data.quality === "backup") {
results.push(await format(data.url));
}
}),
);
await Promise.all(
baseData.map(async (data) => {
const _ = data.url.split("/")[4];
switch (data.name) {
case "Streamwish":
results.push(await streamwish({ url: "https://streamwish.to/" + _ }));
break;
case "Doodstream":
results.push(await doodstream({ url: "https://d000d.com/e/" + _ }));
break;
case "Vidhide":
break;
}
}),
);
return c.html(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${metaData.title}</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;700&display=swap');
html,
body {
font-family: 'Lexend';
margin: 0;
padding: 0;
height: 100%;
width: 100%;
overflow: hidden;
font-family: sans-serif;
background: #090909;
color: #ddd;
position: relative;
}
#server-select-server {
position: absolute;
top: 5px;
left: 5px;
padding: 5px;
}
select {
background: #FFF;
color: #000;
border: 2px solid black;
border-radius: 7px;
z-index: 100;
}
#player {