Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

RunKit + npm: youtube-transcript

node v18.11.0
version: 2.0.0
endpointsharetweet
const express = require('express'); const app = express(); const { YoutubeTranscript } = require('youtube-transcript'); app.get('/transcript', async (req, res) => { try { // Extract the YouTube URL from the query parameter 'videoUrl' const videoUrl = req.query.videoUrl; // Check if the videoUrl is provided if (!videoUrl) { return res.status(400).send('No YouTube URL provided'); } // Fetch the transcript const transcript = await YoutubeTranscript.fetchTranscript(videoUrl); let fullTranscript = transcript.map(entry => entry.text).join(" "); // Send the transcript in the response res.send(fullTranscript); } catch (error) { console.error('Error:', error); res.status(500).send(error.message); } }); exports.endpoint = app;
Created from: https://npm.runkit.com/youtube-transcript
Loading…

no comments

    sign in to comment