2023-07-30 08:49:23 +00:00
|
|
|
class SearchModel {
|
|
|
|
constructor() {
|
|
|
|
this.source_models = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
registerSourceModel(source_model) {
|
|
|
|
this.source_models[source_model.getName()] = source_model;
|
|
|
|
}
|
|
|
|
|
|
|
|
getSourceList() {
|
|
|
|
return Object.keys(this.source_models);
|
|
|
|
}
|
|
|
|
|
2023-07-31 16:29:59 +00:00
|
|
|
async searchMusic(source_name, keywords) {
|
2023-07-30 08:49:23 +00:00
|
|
|
if(this.source_models.hasOwnProperty(source_name)) {
|
2023-07-31 16:29:59 +00:00
|
|
|
return await this.source_models[source_name].search(keywords);
|
2023-07-30 08:49:23 +00:00
|
|
|
}else {
|
|
|
|
return "无效的搜索源";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
SearchModel
|
|
|
|
}
|