backend playlist updating endpoint implemented

tomp3/tomp4 errors are now logged
This commit is contained in:
Isaac Grynsztein
2020-02-24 03:51:11 -05:00
parent c069672e62
commit 414b6a26d9

View File

@@ -417,6 +417,7 @@ app.post('/tomp3', function(req, res) {
}
if (err) {
audiopath = "-1";
console.log(err.stderr);
res.sendStatus(500);
throw err;
} else if (output) {
@@ -478,6 +479,7 @@ app.post('/tomp4', function(req, res) {
}
if (err) {
videopath = "-1";
console.log(err.stderr);
res.sendStatus(500);
throw err;
} else if (output) {
@@ -661,6 +663,32 @@ app.post('/createPlaylist', async (req, res) => {
})
});
app.post('/updatePlaylist', async (req, res) => {
let playlistID = req.body.playlistID;
let fileNames = req.body.fileNames;
let type = req.body.type;
let success = false;
try {
db.get(`playlists.${type}`)
.find({id: playlistID})
.assign({fileNames: fileNames})
.write();
/*console.log('success!');
let new_val = db.get(`playlists.${type}`)
.find({id: playlistID})
.value();
console.log(new_val);*/
success = true;
} catch(e) {
console.error(`Failed to find playlist with ID ${playlistID}`);
}
res.send({
success: success
})
});
app.post('/deletePlaylist', async (req, res) => {
let playlistID = req.body.playlistID;
let type = req.body.type;