60 lines
1.2 KiB
JavaScript
60 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const Service = require('egg').Service;
|
|
|
|
class KuGouService extends Service {
|
|
async getSearchSongList(param) {
|
|
try {
|
|
const header = {
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
data: {
|
|
...param,
|
|
_: Date.now(),
|
|
},
|
|
};
|
|
const url = 'http://songsearch.kugou.com/song_search_v2';
|
|
const res = await this.ctx.curl(url, header);
|
|
return res.data;
|
|
} catch (err) {
|
|
throw new Error(err);
|
|
}
|
|
}
|
|
async getNewSongList(param) {
|
|
try {
|
|
const header = {
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
data: {
|
|
...param,
|
|
_: Date.now(),
|
|
},
|
|
};
|
|
const url = 'http://m.kugou.com/';
|
|
const res = await this.ctx.curl(url, header);
|
|
return res.data;
|
|
} catch (err) {
|
|
throw new Error(err);
|
|
}
|
|
}
|
|
async getSongMsg(hash) {
|
|
try {
|
|
const header = {
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
data: {
|
|
hash,
|
|
r: 'play/getdata',
|
|
},
|
|
};
|
|
const url = 'http://www.kugou.com/yy/index.php';
|
|
const res = await this.ctx.curl(url, header);
|
|
return res.data;
|
|
} catch (err) {
|
|
throw new Error(err);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = KuGouService;
|