Public
Script
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
// Import Cheerio and CryptoJS from npm
import cheerio from "npm:cheerio";
import CryptoJS from "npm:crypto-js";
class AnimeScraper {
constructor(url) {
this.url = url;
this.result = [];
this.results = {
sourceA: "",
sourceB: "",
sourceC: "",
sourceD: "",
sourceE: "",
};
this.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "en-US,en;q=0.5",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "same-origin",
"X-Requested-With": "XMLHttpRequest",
"Priority": "u=4",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
};
}
async fetchPage() {
try {
const response = await fetch(this.url, { headers: this.headers });
if (!response.ok) throw new Error(`Failed to fetch page: ${response.statusText}`);
const $ = cheerio.load(await response.text());
const listItems = $(".anime_muti_link li");
// Select all list items under the <ul> and extract the data
this.result = listItems
.map((_, element) => {
const $element = $(element);
const $anchor = $element.find("a");
return {
class: $element.attr("class") || "",
rel: $anchor.attr("rel"),
video: $anchor.attr("data-video"),
text: $anchor.contents().first().text().trim(),
};
})
.get();
} catch (error) {
console.error("Error:", error);
}
}
async processServers() {
for (const server of this.result) {
if (server.class === "vidcdn") {
const data = await extract(server.video);
this.results.sourceA = data.source[0].file;
this.results.sourceB = data.source_bk[0].file;
}
console.log(server.class);
if (server.class === "doodstream") {
const id = server.video.split("/")[4];
const data = await (await fetch(`https://tempguy-scarletsole.web.val.run/dood/${id}`)).json();
this.results.sourceC = data.stream[0].qualities.unknown.url;
}
if (server.class === "streamwish") this.results.sourceD = server.video;
if (server.class === "vidhide") this.results.sourceE = server.video;
}
console.log(this.results);
}
}
// Extract function to process encrypted data
async function extract(url) {
try {
const response = await fetch(url, {
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "en-US,en;q=0.5",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "same-origin",
"X-Requested-With": "XMLHttpRequest",
"Priority": "u=4",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
},
});
if (!response.ok) throw new Error(`Failed to fetch data: ${response.statusText}`);
const text = await response.text();
const $ = cheerio.load(text);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 27, 2024