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