-
Notifications
You must be signed in to change notification settings - Fork 102
/
gakiarchives.com.js
99 lines (90 loc) · 2.65 KB
/
gakiarchives.com.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
// ==MiruExtension==
// @name GakiArchives
// @version v0.0.1
// @author bachig26
// @lang en
// @license MIT
// @package gakiarchives.com
// @type bangumi
// @icon https://gakiarchives.com/images/logo.png
// @webSite https://gakiarchives.com
// @nsfw false
// ==/MiruExtension==
export default class extends Extension {
async latest(page) {
const res = await this.request(`/all`);
const bsxList = await this.querySelectorAll(res, "div.owl-items.w-25");
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, "h2").text;
const cover = await this.querySelector(html, "img").getAttributeText("src");
novel.push({
title: title.trim(),
url: "https://gakiarchives.com" + url,
cover: "https://gakiarchives.com" + cover,
});
}
return novel;
}
async search(kw) {
const kwstring = kw.replace(/ /g, '+');
const res = await this.request(`/search/${kwstring}`);
const bsxList = await this.querySelectorAll(res, "div.owl-items.w-25");
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, "h2").text;
const cover = await this.querySelector(html, "img").getAttributeText("src");
novel.push({
title: title.trim(),
url: "https://gakiarchives.com" + url,
cover: "https://gakiarchives.com" + cover,
});
}
return novel;
}
async detail(url) {
const res = await this.request('', {
headers: {
"Miru-Url": url,
},
});
const title = await this.querySelector(res, "div.card-header > h3").text;
const cover = res.match(/pic:\s*'([^']+?)'/)[1];
const desc = await this.querySelector(res, "i.far.fa-folder + a").text;
const urlPatterns = [/https?:\/\/[^\s'"]+\.(?:m3u8)/];
let episodeUrl = "";
for (const pattern of urlPatterns) {
const match = res.match(pattern);
if (match) {
episodeUrl = match[0];
break;
}
}
return {
title: title.trim(),
cover: "https://gakiarchives.com" + cover,
desc: desc.trim(),
episodes: [
{
title: "Directory",
urls: [
{
name: title,
url: episodeUrl,
},
],
},
],
};
}
async watch(url) {
return {
type: "hls",
url: url || "",
};
}
}