2023-07-31 16:29:59 +00:00
|
|
|
const _request = require('request');
|
|
|
|
|
2023-08-05 04:49:00 +00:00
|
|
|
const exts = ['mp3', 'acc', 'aiff', 'ape', 'au', 'flac', 'm4a', 'mmf', 'opus', 'voc', 'wav', 'ogg', 'ra', 'dvf', 'taa', 'dsf', 'diff', 'dts', 'wma'];
|
|
|
|
|
2023-07-30 08:49:23 +00:00
|
|
|
class SourceModel {
|
|
|
|
constructor() {
|
|
|
|
this.name = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
getName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
2023-08-05 04:49:00 +00:00
|
|
|
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 '';
|
|
|
|
}
|
|
|
|
|
2023-07-31 16:29:59 +00:00
|
|
|
request(options) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
_request(options, function(error, response, body) {
|
|
|
|
if (!error && response.statusCode === 200) {
|
|
|
|
resolve(body);
|
|
|
|
} else {
|
|
|
|
console.log(error);
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async search(keywords) {
|
|
|
|
return [
|
|
|
|
|
|
|
|
];
|
2023-07-30 08:49:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
SourceModel
|
|
|
|
}
|