This repository has been archived by the owner on May 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.js
87 lines (87 loc) · 2.27 KB
/
api.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
const core = require("./lib/core.lib");
let API = {};
API.search = (name,callback,{limit="5",type="1"}={})=>{
if(typeof limit == "number")limit = limit.toString();
if(typeof type == "number")type = type.toString();
if(!name) {throw new Error("Name not Found!!!");return;};
const form = {
s :name,
limit,
total :true,
type,
csrf_token :"",
offset :"0"
};
core.post("http://music.163.com/weapi/cloudsearch/get/web?csrf_token=",form,(data)=>callback(data));
};
API.getAlbum = (id,callback)=>{
if(id == 0) throw new Error("叽叽叽???");
if(typeof id == "number") id = id.toString();
const form = {
album_id :id,
csrf_token :""
};
core.post("http://music.163.com/weapi/v1/album/"+ id +"?csrf_token=",form,(data)=>callback(data));
};
API.getDetail = (id,callback)=>{
let isArr = false;
if(id == 0) throw new Error("叽叽叽???");
if(typeof id == "number"){
id = id.toString();
}else if(Array.isArray(id)){
id = JSON.stringify(id);
isArr = true;
}
const form = {
ids :id,
csrf_token :""
};
core.post("http://music.163.com/weapi/v1/song/detail",form,(data)=>callback(data,isArr));
};
API.getPlaylist = (id,callback)=>{
if(id == 0) throw new Error("叽叽叽???");
const form = {
id,
n :"1000",
csrf_token :""
};
core.post("http://music.163.com/weapi/v3/playlist/detail?csrf_token=",form,(data)=>callback(data));
}
API.getURL = (id,callback,br = "320000")=>{
if(id == 0) throw new Error("喵喵喵???");
if(typeof id == "number"){
id = "["+id+"]";
}else if(Array.isArray(id)){
id = JSON.stringify(id);
}else if(id.substring(0,1)!=="["){
id = "["+id+"]";
}
if(typeof br == "number") br = br.toString();
const form = {
ids :id,
br,
csrf_token :""
};
core.post("http://music.163.com/weapi/song/enhance/player/url?csrf_token=",form,(data)=>callback(data));
}
API.getLyric = (id,callback)=>{
if(id == 0) throw new Error("哞哞哞???");
const form = {
id,
os :"pc",
lv :"-1",
kv :"-1",
tv :"-1",
csrf_token :""
};
core.post("http://music.163.com/weapi/song/lyric?csrf_token=",form,data=>callback(data));
}
API.getMV = (id,callback)=>{
if(id == 0) throw new Error("WTF???");
const form = {
id,
csrf_token:""
}
core.post("http://music.163.com/weapi/mv/detail/",form,(data)=>callback(data));
}
module.exports = API;