优化格式识别
parent
336108efb7
commit
c2bf1b8f5a
|
@ -27,8 +27,8 @@ 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 mfm.MyFreemp35singycSource());
|
||||
// searcher.registerSourceModel(new mfm.MyFreemp35singfcSource());
|
||||
|
||||
|
||||
// ***********************************************************************
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
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();
|
||||
this.type = 'qq';
|
||||
this.name = "MyFreemp3_QQ";
|
||||
this.type = '';
|
||||
this.name = '';
|
||||
}
|
||||
|
||||
getExtension(url) {
|
||||
return url.toLowerCase();
|
||||
}
|
||||
|
||||
async search(keywords) {
|
||||
|
@ -37,7 +56,8 @@ class MyFreemp3Source extends SourceModel {
|
|||
link: item.link,
|
||||
lrc: item.lrc,
|
||||
pic: item.pic,
|
||||
source_name: this.getName()
|
||||
source_name: this.getName(),
|
||||
extension: item.url ? checkExtension(this.getExtension(item.url)) : ''
|
||||
}
|
||||
});
|
||||
}else {
|
||||
|
@ -54,6 +74,10 @@ class MyFreemp3QQSource extends MyFreemp3Source {
|
|||
this.type = 'qq';
|
||||
this.name = "MyFreemp3_QQ";
|
||||
}
|
||||
|
||||
getExtension(url) {
|
||||
return url.split('?')[0].split('/').pop().split('.').pop().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
class MyFreemp3NeteaseSource extends MyFreemp3Source {
|
||||
|
@ -62,6 +86,10 @@ class MyFreemp3NeteaseSource extends MyFreemp3Source {
|
|||
this.type = 'netease';
|
||||
this.name = "MyFreemp3_网易";
|
||||
}
|
||||
|
||||
getExtension(url) {
|
||||
return url.split('.').pop().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
class MyFreemp3KugouSource extends MyFreemp3Source {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<div style="margin: 10px 0">
|
||||
<label>选择搜索源:</label>
|
||||
<Checkbox-Group v-model="selected_sources" style="display: inline-block;">
|
||||
<Checkbox v-for="item in sources" :label="item">{{ item }}</Checkbox>
|
||||
<Checkbox v-for="item in sources" :label="item" style="padding-right:15px;">{{ item }}</Checkbox>
|
||||
</Checkbox-Group>
|
||||
</div>
|
||||
<div style="margin: 10px 0">
|
||||
|
@ -63,7 +63,8 @@
|
|||
<Row style="vertical-align: middle; line-height: 32px;">
|
||||
<i-col span="4">链接:</i-col>
|
||||
<i-col span="20">
|
||||
<a :href="current_item.url" target="_blank" download="download" style="margin-right: 20px;">下载歌曲</a>
|
||||
<a v-if="current_item.url" :href="current_item.url" target="_blank" download="download" style="margin-right: 20px;">下载歌曲</a>
|
||||
<span v-if="!current_item.url" style="margin-right: 20px;color:#aaa;">下载歌曲</span>
|
||||
<a :href="current_item.link" target="_blank">源链接</a>
|
||||
</i-col>
|
||||
</Row>
|
||||
|
@ -105,7 +106,7 @@
|
|||
<i-col span="16">
|
||||
<p style="display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;" :title="item2.title">{{ item2.title }}</p>
|
||||
<p style="color:#bbb">{{ item2.author }}</p>
|
||||
<p><Tag :color="['default','primary','success','error','warning','magenta','red','volcano','orange','gold','yellow'][item2.number%11]">{{ item2.source_name }}</Tag></p>
|
||||
<p><Tag>{{ item2.extension || '未知格式' }}</Tag><Tag :color="['default','primary','success','error','warning','magenta','red','volcano','orange','gold','yellow'][item2.number%11]">{{ item2.source_name }}</Tag></p>
|
||||
</i-col>
|
||||
</Row>
|
||||
</div>
|
||||
|
@ -121,8 +122,8 @@
|
|||
el: "#app",
|
||||
data() {
|
||||
const ajax = axios.create({
|
||||
baseURL: 'http://www.amuliang.top:5750',
|
||||
//baseURL: 'http://localhost:5000',
|
||||
//baseURL: 'http://www.amuliang.top:5750',
|
||||
baseURL: 'http://localhost:5000',
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
|
@ -190,7 +191,6 @@
|
|||
let list = await this.search(selected_sources[i], keywords, result);
|
||||
list.forEach(item => {
|
||||
item.number = i; //主要用来打标记
|
||||
item.extension = getExtension(item.url);
|
||||
result.push(item);
|
||||
});
|
||||
}
|
||||
|
@ -228,6 +228,10 @@
|
|||
handleStore() {
|
||||
this.is_storing = true;
|
||||
this.store_message = '';
|
||||
if(getSelection(this.renderedStorePath) == '') {
|
||||
this.$Message.error("请指定有效歌曲后缀名");
|
||||
return;
|
||||
}
|
||||
this.get('/api/store', {
|
||||
music_path: this.renderedStorePath,
|
||||
music_url: this.current_item.url,
|
||||
|
@ -249,6 +253,10 @@
|
|||
this.is_searching = true;
|
||||
this.get('/api/source/all').then(response => {
|
||||
this.sources = response.data.data;
|
||||
if(this.sources.length > 0) {
|
||||
// 默认选中第一个
|
||||
this.selected_sources = [this.sources[0]];
|
||||
}
|
||||
this.is_searching = false;
|
||||
}).catch(err => {
|
||||
this.$Message.error(err.message);
|
||||
|
@ -273,7 +281,7 @@
|
|||
}
|
||||
|
||||
function getExtension(url) {
|
||||
var ext = url.split('?')[0].split('/').pop().split('.').pop().toLowerCase();
|
||||
var ext = url.split('/').pop().split('.').pop().toLowerCase();
|
||||
var exts = ['mp3', 'acc', 'aiff', 'ape', 'au', 'flac', 'm4a', 'mmf', 'opus', 'voc', 'wav', 'ogg', 'ra', 'dvf', 'taa', 'dsf', 'diff', 'dts', 'wma'];
|
||||
if(exts.indexOf(ext) >= 0) {
|
||||
return ext;
|
||||
|
|
Loading…
Reference in New Issue