85 lines
3.4 KiB
JavaScript
85 lines
3.4 KiB
JavaScript
|
const { SourceModel } = require('../model/SourceModel');
|
|||
|
|
|||
|
class ATYYSource extends SourceModel {
|
|||
|
constructor() {
|
|||
|
super();
|
|||
|
this.type = '';
|
|||
|
this.name = '爱听音乐网';
|
|||
|
}
|
|||
|
|
|||
|
getExtension(url) {
|
|||
|
return url.toLowerCase();
|
|||
|
}
|
|||
|
|
|||
|
async search(keywords) {
|
|||
|
keywords = encodeURIComponent(keywords);
|
|||
|
|
|||
|
// GET请求,获取列表
|
|||
|
// http://www.2t58.com/so/%E4%B8%8D%E5%87%A1.html
|
|||
|
let options_all = {
|
|||
|
url: `http://www.2t58.com/so/${keywords}.html`,
|
|||
|
method: 'GET',
|
|||
|
headers: {
|
|||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|||
|
//'Host': 'myfreemp3.sharerj.com',
|
|||
|
//'Origin': 'http://myfreemp3.sharerj.com',
|
|||
|
//'Referer': `http://myfreemp3.sharerj.com/?name=${keywords}&type=qq`,
|
|||
|
//'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183',
|
|||
|
//'Accept': 'application/json, text/javascript, */*; q=0.01',
|
|||
|
'X-Requested-With': 'XMLHttpRequest', //此行必须填写
|
|||
|
//'Cookie': '__gads=ID=f167a79e430852c8-227b3bd2b6e70079:T=1690680059:RT=1690680059:S=ALNI_MZixvU2-9BVQv0qTuN2kVnZttuZIQ; __gpi=UID=00000d30f9e155c5:T=1690680059:RT=1690680059:S=ALNI_MZtwSz24f5LJ-tGCRKRuzz0AFH5rA'
|
|||
|
},
|
|||
|
//json: true, //将body解析为json
|
|||
|
//body: `input=${keywords}&filter=name&type=${this.type}&page=1`
|
|||
|
};
|
|||
|
|
|||
|
let result_all = await this.request(options_all);
|
|||
|
let ids = [...result_all.matchAll(/\"\/song\/(.*?)\.html\"/g)].map(elem=>elem[1]).slice(0,10)
|
|||
|
|
|||
|
|
|||
|
// POST请求,获取每一个音乐的详细信息
|
|||
|
let result = [];
|
|||
|
for(let i = 0; i < ids.length; i++) {
|
|||
|
let options = {
|
|||
|
url: `http://www.2t58.com/js/play.php`,
|
|||
|
method: 'POST',
|
|||
|
headers: {
|
|||
|
'Host': 'www.2t58.com',
|
|||
|
'Origin': 'http://www.2t58.com',
|
|||
|
'Referer': `http://www.2t58.com/song/${ids[i]}.html`, //此行必须填写
|
|||
|
//'Cookie': 'Hm_lvt_b8f2e33447143b75e7e4463e224d6b7f=1708226055; Hm_lpvt_b8f2e33447143b75e7e4463e224d6b7f=1708226093',
|
|||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|||
|
'X-Requested-With': 'XMLHttpRequest', //此行必须填写
|
|||
|
},
|
|||
|
json: true, //将body解析为json
|
|||
|
body: `id=${ids[i]}&type=music`
|
|||
|
};
|
|||
|
|
|||
|
let item = await this.request(options);
|
|||
|
let result_lrc = await this.request({url:`https://api.44h4.com/lc.php?cid=${item.lkid}`, method:'GET'});
|
|||
|
let lrc = JSON.parse(result_lrc).lrc;
|
|||
|
|
|||
|
console.log(item)
|
|||
|
|
|||
|
result.push({
|
|||
|
title: item.title ? item.title.split(' - ').pop() : '',
|
|||
|
author: item.title ? item.title.split(' - ')[0] : '',
|
|||
|
url: item.url,
|
|||
|
link: `http://www.2t58.com/song/${ids[i]}.html`,
|
|||
|
lrc: lrc,
|
|||
|
pic: item.pic,
|
|||
|
source_name: this.getName(),
|
|||
|
extension: item.url ? this.checkExtension(this.getExtension(item.url)) : ''
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// let test = new ATYYSource();
|
|||
|
// test.search('不凡');
|
|||
|
|
|||
|
module.exports = {
|
|||
|
ATYYSource
|
|||
|
}
|