Add json param to /transcript
| @@ -60,6 +60,7 @@ router.post('/transcript', jsonParser, async (request, response) => { | ||
| 60 | 60 | const RE_XML_TRANSCRIPT = /<text start="([^"]*)" dur="([^"]*)">([^<]*)<\/text>/g; |
| 61 | 61 | const id = request.body.id; |
| 62 | 62 | const lang = request.body.lang; |
| 63 | + const json = request.body.json; | |
| 63 | 64 | |
| 64 | 65 | if (!id) { |
| 65 | 66 | console.log('Id is required for /transcript'); |
| @@ -129,7 +130,9 @@ router.post('/transcript', jsonParser, async (request, response) => { | ||
| 129 | 130 | // The text is double-encoded |
| 130 | 131 | const transcriptText = transcript.map((line) => he.decode(he.decode(line.text))).join(' '); |
| 131 | 132 | |
| 132 | - return response.send(transcriptText); | |
| 133 | + return json | |
| 134 | + ? response.json({ transcript: transcriptText, html: videoPageBody }) | |
| 135 | + : response.send(transcriptText); | |
| 133 | 136 | } catch (error) { |
| 134 | 137 | console.log(error); |
| 135 | 138 | return response.sendStatus(500); |