From 414b6a26d92f0d1051236eb5665f178b01a61e32 Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Mon, 24 Feb 2020 03:51:11 -0500 Subject: [PATCH] backend playlist updating endpoint implemented tomp3/tomp4 errors are now logged --- backend/app.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/backend/app.js b/backend/app.js index 0e7ce67..c1545aa 100644 --- a/backend/app.js +++ b/backend/app.js @@ -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;