-
Notifications
You must be signed in to change notification settings - Fork 105
/
nimegami.id.js
141 lines (129 loc) · 4.12 KB
/
nimegami.id.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// ==MiruExtension==
// @name Nimegami
// @version v0.0.2
// @author JerukPurut404
// @lang id
// @license MIT
// @package nimegami.id
// @type bangumi
// @icon https://nimegami.id/wp-content/uploads/2018/07/Nimegami-anime.png
// @webSite https://nimegami.id
// ==/MiruExtension==
//Current issue: Doesn't work on older animes such as spy x family since it's using video.nimegami.id instead of berkasdrive.com
export default class extends Extension {
async latest() {
const res = await this.request("/");
const bsxList = await this.querySelectorAll(
res,
"div.post-article > article"
);
const novel = [];
for (const element of bsxList) {
const html = await element.content;
let url2 = await this.getAttributeText(html, "div.thumb > a", "href");
url2 = url2.replace('https://nimegami.id', '');
console.log(url2);
const url = url2;
const title = await this.querySelector(html, "h2 > a").text;
const cover = await this.querySelector(
html,
".attachment-post-thumbnail.size-post-thumbnail"
).getAttributeText("src");
novel.push({
title: title.trim(),
url,
cover,
});
}
return novel;
}
async search(kw){
const res = await this.request(`/?s=${kw}&post_type=post`)
const bsxList = await this.querySelectorAll(res, "article")
const novel = [];
for (const element of bsxList){
const html = await element.content;
let url2 = await this.getAttributeText(html, 'div.thumbnail > a', "href");
url2 = url2.replace('https://nimegami.id', '');
console.log(url2);
const url = url2;
const title = await this.querySelector(html, 'h2 > a').text;
const cover = await this.querySelector(html, 'img').getAttributeText("src");
novel.push({
title: title.trim(),
url,
cover
});
}
return novel;
}
async detail(url){
const res = await this.request(url);
const title = await this.querySelector(res, 'h1.title').text
const cover = await this.querySelector(res, 'img[itemprop="image"]').getAttributeText("src");
const desc = "No Desc Avaliable";
const episodes_360p = [];
const episodes_480p = [];
const episodes_720p = [];
const epiList = await this.querySelectorAll(res, "div.list_eps_stream > li");
for (const element of epiList) {
const html = await element.content;
const name = await this.querySelector(html, ".select-eps").text;
const ep_url = await this.getAttributeText(html, ".select-eps", "data");
const words = CryptoJS.enc.Base64.parse(ep_url);
const textString = CryptoJS.enc.Utf8.stringify(words);
const regex_360 = /"format":"360p","url":\["([^"]+)","([^"]+)"]/;
const regex_480 = /"format":"480p","url":\["([^"]+)","([^"]+)"]/;
const regex_720 = /"format":"720p","url":\["([^"]+)","([^"]+)"]/;
const match_360 = textString.match(regex_360);
const match_480 = textString.match(regex_480);
const match_720 = textString.match(regex_720);
const url = match_360 ? match_360[2] : "";
const url_480 = match_480 ? match_480[2] : "";
const url_720 = match_720 ? match_720[2] : "";
episodes_360p.push({
name: name.trim(),
url,
});
episodes_480p.push({
name: name.trim(),
url: url_480,
});
episodes_720p.push({
name: name.trim(),
url: url_720,
});
}
return{
title: title.trim(),
cover: cover,
desc: desc,
episodes:[{
title: '360p',
urls: episodes_360p.reverse()
},
{
title: '480p',
urls: episodes_480p.reverse()
},
{
title: '720p',
urls: episodes_720p.reverse()
}]
}
}
async watch(url) {
console.log(url)
const chec = url.replace(/\\\//g, "/");
const res = await this.request('', {
headers: {
"Miru-Url": chec,
},
});
const video_url = res.match(/<source src="(.+?.mp4)"/)[1];
return {
type: "hls",
url: video_url || "",
};
}
}