-
Notifications
You must be signed in to change notification settings - Fork 105
/
dramacool.pa.js
89 lines (83 loc) · 2.42 KB
/
dramacool.pa.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
// ==MiruExtension==
// @name DramaCool
// @version v0.0.3
// @author OshekharO
// @lang en
// @license MIT
// @icon https://proxy.techzbots1.workers.dev/?u=https://dramacool.pa/images/mobi/logo.png
// @package dramacool.pa
// @type bangumi
// @webSite https://proxy.techzbots1.workers.dev/?u=https://nontan-source-kgw9jch3s-imkryp70n.vercel.app/movies/dramacool
// ==/MiruExtension==
export default class extends Extension {
async req(url) {
return this.request(url, {
headers: {
"Miru-Url": await this.getSetting("dramacool"),
},
});
}
async load() {
this.registerSetting({
title: "Dramacool API",
key: "dramacool",
type: "input",
description: "Dramacool Api Url",
defaultValue: "https://proxy.techzbots1.workers.dev/?u=https://nontan-source-kgw9jch3s-imkryp70n.vercel.app/movies/dramacool",
});
}
async latest() {
const res = await this.request("", {
headers: {
"Miru-Url": "https://proxy.techzbots1.workers.dev/?u=https://dramacool.pa/most-popular-drama",
},
});
const bsxList = await this.querySelectorAll(res, "ul.switch-block.list-episode-item > li");
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, "h3").text;
const cover = await this.querySelector(html, "img").getAttributeText("data-original");
//console.log(title+cover+url)
novel.push({
title,
url: url.replace("https://dramacool.pa/", ""),
cover,
});
}
return novel;
}
async detail(url) {
const res = await this.req(`/info?id=${url}`);
return {
title: res.title,
cover: res.image,
desc: res.description,
episodes: [
{
title: "Directory",
urls: res.episodes.map((item) => ({
name: item.title,
url: item.id,
})),
},
],
};
}
async search(kw, page) {
const res = await this.req(`/${kw}?page=${page}`);
return res.results.map((item) => ({
title: item.title,
url: item.id,
cover: item.image,
}));
}
async watch(url) {
const res = await this.req(`/watch?episodeId=${url}&server=streamsb`);
return {
type: "hls",
url: res.sources[0].url,
};
}
}