-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathunimay.media.js
75 lines (67 loc) · 1.81 KB
/
unimay.media.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
// ==MiruExtension==
// @name Unimay
// @version v0.0.1
// @author CakesTwix
// @lang uk
// @license GPL3
// @icon https://www.google.com/s2/favicons?domain=unimay.media&sz=256
// @package unimay.media
// @type bangumi
// @webSite https://api.unimay.media
// ==/MiruExtension==
export default class extends Extension {
async req(url) {
return this.request(url, {
headers: {
"Miru-Url": await this.getSetting("unimay"),
},
});
}
async load() {
this.registerSetting({
title: "Unimay API",
key: "unimay",
type: "input",
description: "Unimay API",
defaultValue: "https://api.unimay.media",
});
}
async latest(page) {
const res = await this.req(`/api/release/all?page=${page}`);
return res.releases.map((item) => ({
title: item.name,
url: `/api/release/${item.code}`,
cover: `https://api.unimay.media/storage/images/${item.imageId}`,
}));
}
async detail(url) {
const res = await this.req(url);
return {
title: res.name,
cover: `https://api.unimay.media/storage/images/${res.imageId}`,
desc: res.description,
episodes: [{
title: "Епізоди",
urls: res.playlist.map((item) => ({
name: `${item.title}`,
url: item.playlist,
})),
},],
};
}
async search(kw, page) {
const res = await this.req(`/api/release/search/?title=${kw}&page=${page}`);
return res.releases.map((item) => ({
title: item.name,
url: `/api/release/${item.code}`,
cover: `https://api.unimay.media/storage/images/${item.imageId}`,
desc: item.description,
}));
}
async watch(url) {
return {
type: "hls",
url: url,
};
}
}