From dff4b141b0506b2664a3a838e5af24627002bdde Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Mon, 12 Oct 2020 22:47:11 -0400 Subject: [PATCH] Blobs are now only included in getAllFiles() if the config option for including thumbnail is set to true --- backend/app.js | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/backend/app.js b/backend/app.js index 2d8bd7a..f316c11 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1936,11 +1936,13 @@ app.get('/api/getMp3s', optionalJwt, function(req, res) { mp3s = JSON.parse(JSON.stringify(mp3s)); - // add thumbnails if present - mp3s.forEach(mp3 => { - if (mp3['thumbnailPath'] && fs.existsSync(mp3['thumbnailPath'])) - mp3['thumbnailBlob'] = fs.readFileSync(mp3['thumbnailPath']); - }); + if (config_api.getConfigItem('ytdl_include_thumbnail')) { + // add thumbnails if present + mp3s.forEach(mp3 => { + if (mp3['thumbnailPath'] && fs.existsSync(mp3['thumbnailPath'])) + mp3['thumbnailBlob'] = fs.readFileSync(mp3['thumbnailPath']); + }); + } res.send({ mp3s: mp3s, @@ -1963,11 +1965,13 @@ app.get('/api/getMp4s', optionalJwt, function(req, res) { mp4s = JSON.parse(JSON.stringify(mp4s)); - // add thumbnails if present - mp4s.forEach(mp4 => { - if (mp4['thumbnailPath'] && fs.existsSync(mp4['thumbnailPath'])) - mp4['thumbnailBlob'] = fs.readFileSync(mp4['thumbnailPath']); - }); + if (config_api.getConfigItem('ytdl_include_thumbnail')) { + // add thumbnails if present + mp4s.forEach(mp4 => { + if (mp4['thumbnailPath'] && fs.existsSync(mp4['thumbnailPath'])) + mp4['thumbnailBlob'] = fs.readFileSync(mp4['thumbnailPath']); + }); + } res.send({ mp4s: mp4s, @@ -2055,12 +2059,14 @@ app.post('/api/getAllFiles', optionalJwt, function (req, res) { files = JSON.parse(JSON.stringify(files)); - // add thumbnails if present - files.forEach(file => { - if (file['thumbnailPath'] && fs.existsSync(file['thumbnailPath'])) - file['thumbnailBlob'] = fs.readFileSync(file['thumbnailPath']); - }); - + if (config_api.getConfigItem('ytdl_include_thumbnail')) { + // add thumbnails if present + files.forEach(file => { + if (file['thumbnailPath'] && fs.existsSync(file['thumbnailPath'])) + file['thumbnailBlob'] = fs.readFileSync(file['thumbnailPath']); + }); + } + res.send({ files: files, playlists: playlists @@ -2166,7 +2172,8 @@ app.post('/api/createCategory', optionalJwt, async (req, res) => { const new_category = { name: name, uid: uuid(), - rules: [] + rules: [], + custom_putput: '' }; db.get('categories').push(new_category).write();