diff --git a/src/audio.js b/src/audio.js index cc5f458..aa05721 100644 --- a/src/audio.js +++ b/src/audio.js @@ -8,7 +8,7 @@ const router = express.Router(); router.post('/generate/final', jsonParser, async function (request, response) { console.log('Silence Stitching:'); const contextName = request.body.contextName; - console.log(contextName) + console.log(contextName); const savepath = await audioSilenceStitch(contextName); response.json({ savepath }); }); diff --git a/src/audioSilenceStitch.js b/src/audioSilenceStitch.js index 5d98019..fbc2fd4 100644 --- a/src/audioSilenceStitch.js +++ b/src/audioSilenceStitch.js @@ -80,6 +80,7 @@ async function audioSilenceStitch(contextName) { // console.log(prevEndTime); } // Save the updated contextChunks back to the JSON file + json.overlayAudio = path.basename(outputFile); await saveJson(jsonPath, json); } else { console.log("subs already updated"); diff --git a/src/youtube.js b/src/youtube.js index a56a2fa..7652a9f 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -43,6 +43,8 @@ router.post('/download/context', jsonParser, async function (request, response) const contextPath = path.join('public', 'context', request.body.context); const jsonPath = await getJson(contextPath, true); const json = await loadJson(jsonPath); + const datasheetJsonPath = await getJson(contextPath); + const datasheetJson = await loadJson(datasheetJsonPath); const url = json.webpage_url; console.log('Downloading video:', url); // const filename = ytdlpSanitize(json.title + '-' + json.id + '.mp4'); @@ -78,7 +80,10 @@ router.post('/download/context', jsonParser, async function (request, response) const result = await ytDlpWrap.execPromise(options); console.log(result); - const downloadedFile = parseFilenameFromResult(result); + const downloadedFile = path.basename(parseFilenameFromResult(result)); + datasheetJson.original = downloadedFile; + await fs.promises.writeFile(datasheetJsonPath, JSON.stringify(datasheetJson, null, 2)); + console.log('Downloaded file:', downloadedFile); response.json({ filename: downloadedFile });