Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: youtube-transcript
node v18.11.0
version:
2.0.0
endpoint
share
tweet
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