🐛 Fixed some minor bugs
Some directories were pointed wrong.
This commit is contained in:
parent
e14b0364d5
commit
af97ee82d7
@ -36,14 +36,17 @@ router.get('/get/:type/:id', (req, res, _next) => {
|
|||||||
let db = {};
|
let db = {};
|
||||||
|
|
||||||
if (type === 'song') {
|
if (type === 'song') {
|
||||||
db = require(rootdir + '/songs.json');
|
db = require(rootdir + 'database/songs.json');
|
||||||
} else if (type === 'album') {
|
} else if (type === 'album') {
|
||||||
db = require(rootdir + '/albums.json');
|
db = require(rootdir + "database/albums.json");
|
||||||
} else if (type === 'artist') {
|
} else if (type === 'artist') {
|
||||||
db = require(rootdir + '/artists.json');
|
db = require(rootdir + "database/artists.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = id.split(',');
|
if (id === 'all') {
|
||||||
|
res.json({result: db})
|
||||||
|
} else {
|
||||||
|
const arg = id.split(",");
|
||||||
|
|
||||||
if (arg.length > 1) {
|
if (arg.length > 1) {
|
||||||
let result = [];
|
let result = [];
|
||||||
@ -54,13 +57,14 @@ router.get('/get/:type/:id', (req, res, _next) => {
|
|||||||
} else {
|
} else {
|
||||||
res.json({ result: db[id] });
|
res.json({ result: db[id] });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/play/:track', (req, res, _next) => {
|
router.get('/play/:track', (req, res, _next) => {
|
||||||
var key = req.params.track;
|
var key = req.params.track;
|
||||||
|
|
||||||
var music = rootdir + "/music/" + key + ".mp3";
|
var music = rootdir + "music/" + key + ".mp3";
|
||||||
|
|
||||||
var stat = fs.statSync(music);
|
var stat = fs.statSync(music);
|
||||||
range = req.headers.range;
|
range = req.headers.range;
|
||||||
@ -110,13 +114,14 @@ router.get('/search/:query', (req, res, _next) => {
|
|||||||
const query = req.params.query;
|
const query = req.params.query;
|
||||||
let result = [];
|
let result = [];
|
||||||
|
|
||||||
fs.readdir(rootdir + '/database/', (err, files) => {
|
fs.readdir(rootdir + 'database/', (err, files) => {
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
|
|
||||||
const content = require(rootdir + '/database/' + file);
|
const content = require(rootdir + 'database/' + file);
|
||||||
|
|
||||||
content.forEach(element => {
|
content.forEach(element => {
|
||||||
if (element.name.match(query)) {
|
if (element.name.match(query)) {
|
||||||
|
element.foundIn = file;
|
||||||
result.push(element);
|
result.push(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ extends layout
|
|||||||
block content
|
block content
|
||||||
h1= title
|
h1= title
|
||||||
p Welcome to #{title}
|
p Welcome to #{title}
|
||||||
form(action="/download" method="get")
|
form(action="download" method="get")
|
||||||
label(for="url")
|
label(for="url")
|
||||||
input(name="url" type="text")
|
input(name="url" type="text")
|
||||||
input(type="submit")
|
input(type="submit")
|
||||||
|
Loading…
Reference in New Issue
Block a user