From 6feb8326e706312aafcc50ffc92d1a8ebbb58f47 Mon Sep 17 00:00:00 2001 From: amuliang <982632988@qq.com> Date: Sun, 18 Feb 2024 12:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=88=B1=E5=90=AC=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.js | 2 + app/source/ATYYSource.js | 85 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 app/source/ATYYSource.js diff --git a/app/main.js b/app/main.js index 064827a..4819623 100644 --- a/app/main.js +++ b/app/main.js @@ -9,6 +9,7 @@ const { QQSource } = require('./source/QQSource'); const mfm = require('./source/MyFreemp3Source'); const rm123 = require('./source/RM123Source'); const { KugouSource } = require('./source/KugouSource'); +const { ATYYSource } = require('./source/ATYYSource'); const { rm } = require("fs"); // 防止进程中断 @@ -35,6 +36,7 @@ searcher.registerSourceModel(new mfm.MyFreemp31tingSource()); //searcher.registerSourceModel(new KugouSource()); 不能使用 searcher.registerSourceModel(new rm123.RM123MiguSource()); // searcher.registerSourceModel(new rm123.RM123XimalayaSource());不能使用 +searcher.registerSourceModel(new ATYYSource()); // *********************************************************************** diff --git a/app/source/ATYYSource.js b/app/source/ATYYSource.js new file mode 100644 index 0000000..32cbd67 --- /dev/null +++ b/app/source/ATYYSource.js @@ -0,0 +1,85 @@ +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 +} \ No newline at end of file