mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 01:57:29 +00:00
26 lines
564 B
JavaScript
26 lines
564 B
JavaScript
const path = require("path");
|
|
const fs = require("fs");
|
|
|
|
let cache = null;
|
|
|
|
function getCache() {
|
|
if (cache == null) {
|
|
cache = JSON.parse(
|
|
fs.readFileSync(path.join(__dirname, "../info.json"), "utf8")
|
|
);
|
|
}
|
|
return cache;
|
|
}
|
|
|
|
// TODO: Make async and rewriting using DB
|
|
function getInfo(md5) {
|
|
return getCache()[md5];
|
|
}
|
|
|
|
// TODO: Make async and rewriting using DB
|
|
function getFilename(md5) {
|
|
const info = getInfo(md5);
|
|
return info.filePaths.map(filepath => path.basename(filepath))[0];
|
|
}
|
|
|
|
module.exports = { getInfo, getCache, getFilename };
|