diff --git a/app/main.js b/app/main.js index f609c4e..8dbb596 100644 --- a/app/main.js +++ b/app/main.js @@ -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()); // *********************************************************************** diff --git a/app/source/MyFreemp3Source.js b/app/source/MyFreemp3Source.js index d08ef8f..23ca344 100644 --- a/app/source/MyFreemp3Source.js +++ b/app/source/MyFreemp3Source.js @@ -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 { diff --git a/html/index.html b/html/index.html index 89b12de..6b51b41 100644 --- a/html/index.html +++ b/html/index.html @@ -31,7 +31,7 @@