修改源,添加酷狗源
parent
7910b35811
commit
603bdb8478
16
app/main.js
16
app/main.js
|
@ -7,6 +7,7 @@ const { SuccessResult, ErrorResult } = require('./model/ResultModel');
|
|||
|
||||
const { QQSource } = require('./source/QQSource');
|
||||
const mfm = require('./source/MyFreemp3Source');
|
||||
const { KugouSource } = require('./source/KugouSource');
|
||||
|
||||
// 防止进程中断
|
||||
// process.on('uncaughtException', function (err) {
|
||||
|
@ -18,17 +19,18 @@ const searcher = new SearchModel();
|
|||
//searcher.registerSourceModel(new QQSource());
|
||||
searcher.registerSourceModel(new mfm.MyFreemp3QQSource());
|
||||
searcher.registerSourceModel(new mfm.MyFreemp3NeteaseSource());
|
||||
searcher.registerSourceModel(new mfm.MyFreemp3KugouSource());
|
||||
//searcher.registerSourceModel(new mfm.MyFreemp3KugouSource());
|
||||
searcher.registerSourceModel(new mfm.MyFreemp3KuwoSource());
|
||||
searcher.registerSourceModel(new mfm.MyFreemp3MiguSource());
|
||||
//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.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());
|
||||
searcher.registerSourceModel(new KugouSource());
|
||||
|
||||
|
||||
// ***********************************************************************
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
const _request = require('request');
|
||||
|
||||
const exts = ['mp3', 'acc', 'aiff', 'ape', 'au', 'flac', 'm4a', 'mmf', 'opus', 'voc', 'wav', 'ogg', 'ra', 'dvf', 'taa', 'dsf', 'diff', 'dts', 'wma'];
|
||||
|
||||
class SourceModel {
|
||||
constructor() {
|
||||
this.name = "";
|
||||
|
@ -9,6 +11,23 @@ class SourceModel {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
checkExtension(ext) {
|
||||
if(typeof(ext) == 'string' && ext.trim() != '') {
|
||||
ext = ext.toLowerCase();
|
||||
if(exts.indexOf(ext) >= 0) {
|
||||
return ext;
|
||||
}
|
||||
|
||||
for(let i = 0; i < exts.length; i++) {
|
||||
if(ext.indexOf('.'+exts[i]) >= 0) {
|
||||
return exts[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
request(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
_request(options, function(error, response, body) {
|
||||
|
|
|
@ -20,7 +20,7 @@ function storeResource(path, url) {
|
|||
return new Promise((resolve, reject) => {
|
||||
mkdirsSync(_path.dirname(path));
|
||||
const writeableStream = fs.createWriteStream(path);
|
||||
request.get({ url: url, timeout: 10000 }).pipe(writeableStream).on('close', () => {
|
||||
request.get({ url: url, timeout: 20000 }).pipe(writeableStream).on('close', () => {
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
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
|
||||
}
|
|
@ -1,20 +1,5 @@
|
|||
const { SourceModel } = require('../model/SourceModel');
|
||||
|
||||
const exts = ['mp3', 'acc', 'aiff', 'ape', 'au', 'flac', 'm4a', 'mmf', 'opus', 'voc', 'wav', 'ogg', 'ra', 'dvf', 'taa', 'dsf', 'diff', 'dts', 'wma'];
|
||||
function checkExtension(ext) {
|
||||
if(exts.indexOf(ext) >= 0) {
|
||||
return ext;
|
||||
}
|
||||
|
||||
for(let i = 0; i < exts.length; i++) {
|
||||
if(ext.indexOf('.'+exts[i]) >= 0) {
|
||||
return exts[i];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
class MyFreemp3Source extends SourceModel {
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -57,7 +42,7 @@ class MyFreemp3Source extends SourceModel {
|
|||
lrc: item.lrc,
|
||||
pic: item.pic,
|
||||
source_name: this.getName(),
|
||||
extension: item.url ? checkExtension(this.getExtension(item.url)) : ''
|
||||
extension: item.url ? this.checkExtension(this.getExtension(item.url)) : ''
|
||||
}
|
||||
});
|
||||
}else {
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
data() {
|
||||
const ajax = axios.create({
|
||||
baseURL: document.location.href.indexOf('localhost') >= 0 ? 'http://localhost:5750' : 'http://musicdlr.amuliang.top:5750',
|
||||
timeout: 10000,
|
||||
timeout: 20000,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
//'Access-Control-Allow-Origin': true
|
||||
|
|
Loading…
Reference in New Issue