52 lines
2.0 KiB
JavaScript
52 lines
2.0 KiB
JavaScript
const { SourceModel } = require('../model/SourceModel');
|
|
|
|
class MyFreemp3QQSource extends SourceModel {
|
|
constructor() {
|
|
super();
|
|
this.name = "MyFreemp3_QQ";
|
|
}
|
|
|
|
async search(keywords) {
|
|
keywords = encodeURIComponent(keywords);
|
|
// POST请求
|
|
let options = {
|
|
url: `http://myfreemp3.sharerj.com/?name=${keywords}&type=qq`,
|
|
method: 'POST',
|
|
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=qq&page=1`
|
|
};
|
|
|
|
let result = await this.request(options);
|
|
if(result.data instanceof Array) {
|
|
result = result.data.map(item => {
|
|
return {
|
|
title: item.title,
|
|
author: item.author,
|
|
url: item.url,
|
|
link: item.link,
|
|
lrc: item.lrc,
|
|
pic: item.pic,
|
|
source_name: this.getName()
|
|
}
|
|
});
|
|
}else {
|
|
result = result;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
MyFreemp3QQSource
|
|
} |