pi-rfid-jukebox/jukebox/library/file-backend.js

26 lines
448 B
JavaScript

"use strict";
const glob = require('glob');
const basename = require('path').basename;
class FileBackend {
constructor(config) {
this.config = config;
}
find(tag, callback) {
glob('media/' + tag + ' - *.mp3', (err, files) => {
if (files.length > 0) {
callback(basename(files[0]));
}
callback();
});
}
}
module.exports = function(config) {
return new FileBackend(config);
};
// vim:ts=2 sw=2 et: