mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add json param to /transcript
This commit is contained in:
@@ -60,6 +60,7 @@ router.post('/transcript', jsonParser, async (request, response) => {
|
|||||||
const RE_XML_TRANSCRIPT = /<text start="([^"]*)" dur="([^"]*)">([^<]*)<\/text>/g;
|
const RE_XML_TRANSCRIPT = /<text start="([^"]*)" dur="([^"]*)">([^<]*)<\/text>/g;
|
||||||
const id = request.body.id;
|
const id = request.body.id;
|
||||||
const lang = request.body.lang;
|
const lang = request.body.lang;
|
||||||
|
const json = request.body.json;
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
console.log('Id is required for /transcript');
|
console.log('Id is required for /transcript');
|
||||||
@@ -129,7 +130,9 @@ router.post('/transcript', jsonParser, async (request, response) => {
|
|||||||
// The text is double-encoded
|
// The text is double-encoded
|
||||||
const transcriptText = transcript.map((line) => he.decode(he.decode(line.text))).join(' ');
|
const transcriptText = transcript.map((line) => he.decode(he.decode(line.text))).join(' ');
|
||||||
|
|
||||||
return response.send(transcriptText);
|
return json
|
||||||
|
? response.json({ transcript: transcriptText, html: videoPageBody })
|
||||||
|
: response.send(transcriptText);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return response.sendStatus(500);
|
return response.sendStatus(500);
|
||||||
|
Reference in New Issue
Block a user