-
Notifications
You must be signed in to change notification settings - Fork 102
/
kimcartoon.li.js
122 lines (107 loc) · 3.26 KB
/
kimcartoon.li.js
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// ==MiruExtension==
// @name KimCartoon
// @version v0.0.2
// @author OshekharO
// @lang en
// @license MIT
// @package kimcartoon.li
// @type bangumi
// @icon https://kimcartoon.li/Content/images/favicon.ico
// @webSite https://kimcartoon.li
// ==/MiruExtension==
export default class extends Extension {
async latest() {
const res = await this.request("/");
const bsxList = await this.querySelectorAll(res, "div.item");
const novel = [];
for (const element of bsxList) {
const html = await element.content;
const url = await this.getAttributeText(html, "a", "href");
const title = await this.querySelector(html, "div.info > a").text;
const cover = await this.querySelector(html, "img").getAttributeText("src");
novel.push({
title: title.trim(),
url,
cover: "https://kimcartoon.li" + cover,
});
}
return novel;
}
async search(kw) {
const res = await this.request("", {
headers: {
"Miru-Url": "https://kimcartoon.li/Search/Cartoon",
"Content-Type": "application/x-www-form-urlencoded",
},
data: {
keyword: kw,
},
method: "Post",
});
const bsxList = await this.querySelectorAll(res, "div.section.group.list");
const novel = [];
for (const element of bsxList) {
const html = await element.content;
const url = await this.getAttributeText(html, "div.col.info > p > a", "href");
const title = await this.querySelector(html, "div.col.info > p > a").text;
const cover = await this.querySelector(html, "img").getAttributeText("src");
novel.push({
title: title.trim(),
url,
cover: "https://kimcartoon.li" + cover,
});
}
return novel;
}
async detail(url) {
const res = await this.request(`${url}`, {
headers: {
"miru-referer": "https://kimcartoon.li/",
},
});
const title = await this.querySelector(res, "div.heading > h3").text;
const cover = await this.querySelector(res, "div.col.cover > img").getAttributeText("src");
const desc = await this.querySelector(res, "div.summary1 > p").text;
const episodes = [];
const epiList = await this.querySelectorAll(res, "ul.list > li");
for (const element of epiList) {
const html = await element.content;
const name = await this.querySelector(html, "a").text;
const url = await this.getAttributeText(html, "a", "href");
episodes.push({
name,
url: "https://kimcartoon.li" + url + "&s=vm",
});
}
return {
title,
cover,
desc,
episodes: [
{
title: "Chapters",
urls: episodes.reverse(),
},
],
};
}
async watch(url) {
const res = await this.request("", {
headers: {
"Miru-Url": url,
},
});
const dwishLink = res.match(/https:\/\/vidmoly\.to\/[^\s'"]+/);
const dwishLinkRes = await this.request("", {
headers: {
"Miru-Url": dwishLink,
},
});
const directUrlMatch = dwishLinkRes.match(/(https:\/\/[^\s'"]*\.m3u8[^\s'"]*)/);
const directUrl = directUrlMatch ? directUrlMatch[0] : "";
return {
type: "hls",
url: directUrl || "",
};
}
}