From 5f58cbfe3b8d6fc1bf31d5decb0a68923c2d48c7 Mon Sep 17 00:00:00 2001 From: amuliang <982632988@qq.com> Date: Wed, 2 Aug 2023 22:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.js | 18 +++- app/source/MyFreemp3QQSource.js | 52 ---------- app/source/MyFreemp3Source.js | 173 ++++++++++++++++++++++++++++++++ html/index.html | 2 +- server.sh | 7 -- start.sh | 11 -- html.sh => start/html.sh | 3 + start/server.sh | 11 ++ start/start.sh | 10 ++ 9 files changed, 213 insertions(+), 74 deletions(-) delete mode 100644 app/source/MyFreemp3QQSource.js create mode 100644 app/source/MyFreemp3Source.js delete mode 100644 server.sh delete mode 100644 start.sh rename html.sh => start/html.sh (65%) create mode 100644 start/server.sh create mode 100644 start/start.sh diff --git a/app/main.js b/app/main.js index 8df1691..f609c4e 100644 --- a/app/main.js +++ b/app/main.js @@ -6,7 +6,7 @@ const { storeMusic, storeLrc, storePic } = require('./model/StoreModel'); const { SuccessResult, ErrorResult } = require('./model/ResultModel'); const { QQSource } = require('./source/QQSource'); -const { MyFreemp3QQSource } = require('./source/MyFreemp3QQSource'); +const mfm = require('./source/MyFreemp3Source'); // 防止进程中断 // process.on('uncaughtException', function (err) { @@ -15,8 +15,20 @@ const { MyFreemp3QQSource } = require('./source/MyFreemp3QQSource'); // *********************************************************************** // 注册源 const searcher = new SearchModel(); -searcher.registerSourceModel(new QQSource()); -searcher.registerSourceModel(new MyFreemp3QQSource()); +//searcher.registerSourceModel(new QQSource()); +searcher.registerSourceModel(new mfm.MyFreemp3QQSource()); +searcher.registerSourceModel(new mfm.MyFreemp3NeteaseSource()); +searcher.registerSourceModel(new mfm.MyFreemp3KugouSource()); +searcher.registerSourceModel(new mfm.MyFreemp3KuwoSource()); +searcher.registerSourceModel(new mfm.MyFreemp3MiguSource()); +searcher.registerSourceModel(new mfm.MyFreemp3QianqianSource()); +searcher.registerSourceModel(new mfm.MyFreemp3QingtingSource()); +searcher.registerSourceModel(new mfm.MyFreemp3XimalayaSource()); +searcher.registerSourceModel(new mfm.MyFreemp3LizhiSource()); +searcher.registerSourceModel(new mfm.MyFreemp3KgSource()); +searcher.registerSourceModel(new mfm.MyFreemp31tingSource()); +searcher.registerSourceModel(new mfm.MyFreemp35singycSource()); +searcher.registerSourceModel(new mfm.MyFreemp35singfcSource()); // *********************************************************************** diff --git a/app/source/MyFreemp3QQSource.js b/app/source/MyFreemp3QQSource.js deleted file mode 100644 index f180009..0000000 --- a/app/source/MyFreemp3QQSource.js +++ /dev/null @@ -1,52 +0,0 @@ -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 -} \ No newline at end of file diff --git a/app/source/MyFreemp3Source.js b/app/source/MyFreemp3Source.js new file mode 100644 index 0000000..d5951dc --- /dev/null +++ b/app/source/MyFreemp3Source.js @@ -0,0 +1,173 @@ +const { SourceModel } = require('../model/SourceModel'); + +class MyFreemp3Source { + +} + +class MyFreemp3Source extends SourceModel { + constructor() { + super(); + this.type = 'qq'; + this.name = "MyFreemp3_QQ"; + } + + async search(keywords) { + keywords = encodeURIComponent(keywords); + // POST请求 + let options = { + url: `http://myfreemp3.sharerj.com/?name=${keywords}&type=${this.type}`, + 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=${this.type}&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; + } +} + +class MyFreemp3QQSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'qq'; + this.name = "MyFreemp3_QQ"; + } +} + +class MyFreemp3NeteaseSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'netease'; + this.name = "MyFreemp3_网易"; + } +} + +class MyFreemp3KugouSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'kugou'; + this.name = "MyFreemp3_酷狗"; + } +} + +class MyFreemp3KuwoSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'kuwo'; + this.name = "MyFreemp3_酷我"; + } +} + +class MyFreemp3QianqianSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'baidu'; + this.name = "MyFreemp3_千千"; + } +} + +class MyFreemp31tingSource extends MyFreemp3Source { + constructor() { + super(); + this.type = '1ting'; + this.name = "MyFreemp3_一听"; + } +} + +class MyFreemp3MiguSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'migu'; + this.name = "MyFreemp3_咪咕"; + } +} + +class MyFreemp3LizhiSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'lizhi'; + this.name = "MyFreemp3_荔枝"; + } +} + +class MyFreemp3QingtingSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'qingting'; + this.name = "MyFreemp3_蜻蜓"; + } +} + +class MyFreemp3XimalayaSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'ximalaya'; + this.name = "MyFreemp3_喜马拉雅"; + } +} + +class MyFreemp35singycSource extends MyFreemp3Source { + constructor() { + super(); + this.type = '5singyc'; + this.name = "MyFreemp3_5sing原创"; + } +} + +class MyFreemp35singfcSource extends MyFreemp3Source { + constructor() { + super(); + this.type = '5singfc'; + this.name = "MyFreemp3_5sing翻唱"; + } +} + +class MyFreemp3KgSource extends MyFreemp3Source { + constructor() { + super(); + this.type = 'kg'; + this.name = "MyFreemp3_全民K歌"; + } +} + +module.exports = { + MyFreemp3QQSource, + MyFreemp3NeteaseSource, + MyFreemp3KugouSource, + MyFreemp3KuwoSource, + MyFreemp3QianqianSource, + MyFreemp31tingSource, + MyFreemp3MiguSource, + MyFreemp3LizhiSource, + MyFreemp3QingtingSource, + MyFreemp3XimalayaSource, + MyFreemp35singycSource, + MyFreemp35singfcSource, + MyFreemp3KgSource +} \ No newline at end of file diff --git a/html/index.html b/html/index.html index 876c71d..89b12de 100644 --- a/html/index.html +++ b/html/index.html @@ -4,7 +4,7 @@ - Document + 音乐下载器-AML diff --git a/server.sh b/server.sh deleted file mode 100644 index 29c636f..0000000 --- a/server.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# 下载依赖包 -npm install - -# 运行服务器端 -node /music-downloader/app/main.js \ No newline at end of file diff --git a/start.sh b/start.sh deleted file mode 100644 index f5722f8..0000000 --- a/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# 拉取代码 -cd / -git clone http://192.168.1.253:9130/amuliang/music-downloader.git - -# 运行服务 -./server.sh & -./start.sh & - -echo "start success !!!" \ No newline at end of file diff --git a/html.sh b/start/html.sh similarity index 65% rename from html.sh rename to start/html.sh index c2dcbc3..65dbb10 100644 --- a/html.sh +++ b/start/html.sh @@ -3,6 +3,9 @@ # 下载依赖包 npm install http-server -g +wait + # 运行前端页面 cd /music-downloader/html +echo "run html, localhost:8080" http-server -p 8080 \ No newline at end of file diff --git a/start/server.sh b/start/server.sh new file mode 100644 index 0000000..9884db9 --- /dev/null +++ b/start/server.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# 下载依赖包 +cd /music-downloader +npm install + +wait + +# 运行服务器端 +echo "run server, localhost:5000" +node /music-downloader/app/main.js \ No newline at end of file diff --git a/start/start.sh b/start/start.sh new file mode 100644 index 0000000..c312b5d --- /dev/null +++ b/start/start.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# 拉取代码 +git clone http://${REMOTE_ADDR}/amuliang/music-downloader.git /music-downloader +wait + +# 运行服务 +/start/server.sh & +/start/html.sh & +wait \ No newline at end of file