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@3/jsx */
import { fetch as proxyFetch } from "https://esm.town/v/std/fetch";
import { Hono } from "npm:hono";
const Fetch = fetch;
interface ShowBox {
code: number;
msg: string;
server_runtime: number;
server_name: string;
data: {
link: string;
};
}
function getSeasonEpisode(text) {
const pattern = /s(\d{1,3})e(\d{1,4})/i;
const match = text.match(pattern);
if (match) {
return {
season: parseInt(match[1], 10),
episode: parseInt(match[2], 10),
};
} else {
return null;
}
}
const app = new Hono();
const headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Alt-Used": "www.showbox.media",
};
app.get("/stream/:id/", async (c) => {
const { id } = c.req.param();
const post_data = `fid=${id.split(".")[1]}&share_key=${id.split(".")[0]}`;
const streamApiRequest = await fetch(`https://www.febbox.com/file/player?${post_data}`, {
method: "POST",
headers: headers,
});
const urlResponse = await streamApiRequest.text();
console.log(urlResponse);
const regex = /\{"type":(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}/g;
const matches = urlResponse.match(regex);
const responseData = [];
if (matches) {
matches.forEach(match => {
try {
const jsonObject = JSON.parse(match);
responseData.push(jsonObject);
} catch (error) {
console.error("Error", match, error);
}
});
}
return c.json(responseData);
});
app.get("/data/:tmdb/:s?/:e?", async (c) => {
const {
tmdb,
s,
e,
} = c.req.param();
let {
season,
episode,
}: { season: number; episode: number } = { season: Number(s), episode: Number(e) };
const type = (s !== undefined && e !== undefined) ? "S" : "M";
const _tv = (type === "S") ? `.${season}.1` : "";
console.log(_tv);
const idApiRequest = await fetch(`https://api.dmdb.network/v1/gmid/${type}.${tmdb}${_tv}`);
const idApiJson = await idApiRequest.json();
console.log(idApiJson);
if (idApiRequest.status === 404 || idApiJson["ids"].length === 0) {
return c.json([]);
}
const mode = type === "M" ? 1 : 2;
const sheguId = idApiJson["ids"]["superstream"];
const showbox = await fetch(`https://www.showbox.media/index/share_link?id=${sheguId}&type=${mode}`, {
headers: headers,
});
const showboxResponse: ShowBox = await showbox.json();
const febboxId = showboxResponse.data.link.split("/")[4];
const febboxUrl = `https://www.febbox.com/share/${febboxId}`;
console.log(febboxId);
const febboxItemRequest = await fetch(`https://www.febbox.com/file/file_share_list?share_key=${febboxId}`, {
headers: headers,
});
const febboxItemJson = await febboxItemRequest.json();
const febboxFiles = (type === "S")
? await scrapeSeriesFiles(febboxItemJson, febboxId, season, episode)
: await scrapeMoviesFiles(febboxItemJson, febboxId);
const apiResponse = {
id: "",
type: "SERIES",
media: [],
};
for (const item of febboxFiles.data.file_list) {
if (item.file_icon === "video_icon")