-
Notifications
You must be signed in to change notification settings - Fork 105
/
ani.gogo.js
82 lines (74 loc) · 2.16 KB
/
ani.gogo.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
// ==MiruExtension==
// @name AniGoGo
// @version v0.0.3
// @author OshekharO
// @lang en
// @license MIT
// @icon https://anilist.co/img/icons/apple-touch-icon.png
// @package ani.gogo
// @type bangumi
// @webSite https://api.amvstr.me/api/v2
// ==/MiruExtension==
export default class extends Extension {
async req(url) {
return this.request(url, {
headers: {
"Miru-Url": await this.getSetting("amvstrm"),
},
});
}
async load() {
this.registerSetting({
title: "Amvstrm API",
key: "amvstrm",
type: "input",
description: "Amvstrm Api Url",
defaultValue: "https://api.amvstr.me/api/v2",
});
}
async latest() {
const res = await this.req(`/trending`);
return res.results.map((item) => ({
title: item.title.english != null ? item.title.english : "",
url: item.id.toString(),
cover: item.coverImage.extraLarge != null ? item.coverImage.extraLarge : "",
}));
}
async detail(url) {
const res = await this.req(`/info/${url}`);
const epRes = await this.request(`/episode/${url}`);
return {
title: res.title.english != null ? res.title.english : "",
cover: res.coverImage.large != null ? res.coverImage.large : "",
desc: res.description != null ? res.description : "",
episodes: [
{
title: "Episodes",
urls: epRes.episodes.map((item) => ({
name: item.title != null ? item.title : `Episode ${item.number}`,
url: item.id != null ? item.id : "",
})),
},
],
};
}
async search(kw, page) {
const res = await this.req(`/search?q=${kw}&p=${page}&limit=10`);
return res.results.map((item) => {
const title = item.title && item.title.english ? item.title.english : "N/A";
const cover = item.coverImage && item.coverImage.large ? item.coverImage.large : "N/A";
return {
title,
url: item.id.toString(),
cover,
};
});
}
async watch(url) {
const res = await this.req(`/stream/${url}`);
return {
type: "hls",
url: res.stream.multi.main.url,
};
}
}