1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource npm:hono/jsx */
import {
CMDBResponse,
episodeHandler,
play,
search,
seasonHandler,
ServerResponse,
StreamResponse,
watch,
} from "https://esm.town/v/tempdev/backend";
import { Hono } from "npm:hono";
const app = new Hono();
app.get("/", async (c) => {
return c.html(
<div>
<form action="/search">
Search : <input type="text" name="query" /> <input type="submit" />
</form>
</div>,
);
});
app.get("/search", async (c) => {
const searchQuery = c.req.query("query");
const fomattedSearchQuery = searchQuery.replaceAll(" ", "-");
const page = c.req.query("p");
const backendSearch: CMDBResponse = await search(fomattedSearchQuery) as CMDBResponse;
return c.html(
<div>
{backendSearch.results.map(movie => (
<div class="movie">
<h2>{movie.title}</h2>
<img class="poster" src={movie.poster_path} />
<p>{movie.cmid_data}</p>
<p>
<strong>Release Date:</strong> {movie.release_date}
</p>
<p>
<strong>Overview:</strong> <a href={movie.href}>WATCH</a>
</p>
</div>
))}
</div>,
);
});
app.get("/watch/:slug", async (c) => {
const { slug } = c.req.param();
console.log(slug);
const type = atob(slug).split("[.]")[0];
if (type !== "M" && type !== "S") throw new Error();
const id = atob(atob(slug).split("[.]")[1]);
const watchData = await watch(id, type);
console.log(watchData);
return c.html(
<div>
{watchData.map(movie => (
<div class="server">
<a class="link" href={movie.href}>{movie.server}</a>
</div>
))}
</div>,
);
});
app.get("/api/episodes/:slug", async (c) => {
const { slug } = c.req.param();
const episodes = await episodeHandler(slug);
return c.html(
<div>
{episodes.map(episode => (
<button>
<a class="episode" href={episode.href} title={episode.episodeName}>{episode.number}</a>
</button>
))}
</div>,
);
});
app.get("/info/:slug", async (c) => {
const { slug } = c.req.param();
const type = atob(slug).split("[.]")[0];
console.log(atob(slug).split("[.]"));
if (type !== "M" && type !== "S") throw new Error();
const meta = atob(slug).split("[.]");
const [id, title, poster_path] = [atob(meta[1]), atob(meta[2]), atob(meta[3])];
switch (type) {
case "M":
return c.html(
<div>
<div>
title: {title}
<a class="link" href={`/watch/${btoa(type + "[.]" + btoa(id))}`}>WATCH</a>
<img class="poster" src={poster_path} />
</div>
</div>,
);
case "S":
const seriesData = await seasonHandler(id);
return c.html(
<div>
<div>
title: {title}