56 lines
2.3 KiB
JavaScript
56 lines
2.3 KiB
JavaScript
|
const { SourceModel } = require('../model/SourceModel');
|
||
|
|
||
|
class KugouSource extends SourceModel {
|
||
|
constructor() {
|
||
|
super();
|
||
|
this.name = "酷狗";
|
||
|
}
|
||
|
|
||
|
getExtension(url) {
|
||
|
return url.split('.').pop().toLowerCase();
|
||
|
}
|
||
|
|
||
|
async search(keywords) {
|
||
|
keywords = encodeURIComponent(keywords);
|
||
|
|
||
|
let search_result = await this.request({
|
||
|
url: `https://complexsearch.kugou.com/v2/search/song?callback=callback123&srcappid=2919&clientver=1000&clienttime=1691202199922&mid=32acdcbc2dd5869a4d7b70955007e5ff&uuid=32acdcbc2dd5869a4d7b70955007e5ff&dfid=11S8YH0fnvjm1hFwgx32LHUg&keyword=${keywords}&page=1&pagesize=30&bitrate=0&isfuzzy=0&inputtype=0&platform=WebFilter&userid=0&iscorrection=1&privilege_filter=0&filter=10&token=&appid=1014&signature=51f06a76df41782bbb4072a8337575cd`,
|
||
|
method: 'GET'
|
||
|
});
|
||
|
let json_string = search_result.replace(/^[^\(]*\(/, '').replace(/\)[^\)]*$/, '');
|
||
|
let json_data = JSON.parse(json_string);
|
||
|
let list = json_data.data.lists;
|
||
|
|
||
|
let items = [];
|
||
|
let length = list.length > 10 ? 10 : list.length;
|
||
|
for(let i = 0; i < length; i++) {
|
||
|
let item_link = `https://www.kugou.com/mixsong/${list[i].EMixSongID}.html`;
|
||
|
let item_result = await this.request({
|
||
|
url: `https://wwwapi.kugou.com/yy/index.php?r=play/getdata&callback=jQuery19108686411456290846_1691202312384&dfid=11S8YH0fnvjm1hFwgx32LHUg&appid=1014&mid=32acdcbc2dd5869a4d7b70955007e5ff&platid=4&encode_album_audio_id=${list[i].EMixSongID}`,
|
||
|
method: 'GET'
|
||
|
});
|
||
|
let json_string = item_result.replace(/^[^\(]*\(/, '').replace(/\)[^\)]*$/, '');
|
||
|
let json_data = JSON.parse(json_string);
|
||
|
let item = json_data.data;
|
||
|
items.push({
|
||
|
title: item.song_name,
|
||
|
author: item.author_name,
|
||
|
url: item.play_url,
|
||
|
link: item_link,
|
||
|
lrc: item.lyrics,
|
||
|
pic: item.img,
|
||
|
source_name: this.getName(),
|
||
|
extension: item.play_url ? this.checkExtension(this.getExtension(item.play_url)) : ''
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return items;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// let kugou = new KugouSource();
|
||
|
// kugou.search('吻别');
|
||
|
|
||
|
module.exports = {
|
||
|
KugouSource
|
||
|
}
|