2017-04-09 20:57:32 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const glob = require('glob');
|
2017-04-10 02:05:52 +00:00
|
|
|
const basename = require('path').basename;
|
2017-04-09 20:57:32 +00:00
|
|
|
|
|
|
|
class FileBackend {
|
|
|
|
constructor(config) {
|
|
|
|
this.config = config;
|
|
|
|
}
|
|
|
|
|
|
|
|
find(tag, callback) {
|
|
|
|
glob('media/' + tag + ' - *.mp3', (err, files) => {
|
|
|
|
if (files.length > 0) {
|
2017-04-10 02:40:23 +00:00
|
|
|
return callback(basename(files[0]));
|
2017-04-09 20:57:32 +00:00
|
|
|
}
|
2017-04-10 02:05:52 +00:00
|
|
|
callback();
|
2017-04-09 20:57:32 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function(config) {
|
|
|
|
return new FileBackend(config);
|
|
|
|
};
|
|
|
|
|
|
|
|
// vim:ts=2 sw=2 et:
|