-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.js
More file actions
44 lines (33 loc) 路 1.03 KB
/
Copy pathtoken.js
File metadata and controls
44 lines (33 loc) 路 1.03 KB
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
async function getStream(slug, ep = 1) {
const headers = {
"User-Agent": "Mozilla/5.0",
"Referer": "https://anidap.se/",
"Origin": "https://anidap.se"
};
// 1. providers
const servers = await fetch(
`https://anidap.se/api/anime/servers?id=${slug}&ep=${ep}`,
{ headers }
).then(r => r.json());
const provider = servers.data.subProviders[0];
console.log("Using provider:", provider);
// 2. get token
const source = await fetch(
`https://anidap.se/api/anime/sources?id=${slug}&ep=${ep}&host=${provider}&type=sub`,
{ headers }
).then(r => r.json());
console.log("SOURCE RESPONSE:", source);
const token = source.data;
if (!token) throw new Error("Token not found");
// 3. build stream
const stream = `https://cors.otakuu.se/media/${token}`;
return stream;
}
// test
(async () => {
const stream = await getStream(
"classroom-of-the-elite-2nd-year-ucd49",
1
);
console.log("馃帴 STREAM:", stream);
})();