YouTube Transcription
CommunityExtract transcript from a YouTube video URL for summarization.
Installation
Save as `yt-transcript.js`. Requires `youtube-transcript` npm package installed globally or locally.
Source Code
JavaScriptTutorial.terminal
// yt-transcript.js
// Note: This relies on the 'youtube-transcript' library.
// Run: npm install youtube-transcript
const { YoutubeTranscript } = require('youtube-transcript');
module.exports = async function(context) {
const videoUrl = context.args[0];
if (!videoUrl) return { error: "Please provide a YouTube URL" };
try {
const transcript = await YoutubeTranscript.fetchTranscript(videoUrl);
const text = transcript.map(t => t.text).join(' ');
// Return truncated text if too long
return {
summary: text.substring(0, 2000) + "...",
fullLength: text.length
};
} catch (e) {
return { error: e.message };
}
};
Live Preview
β Live DemoAgent Session
How to use
- Ensure you have the necessary dependencies installed (if any).
- Place the file in your OpenClaw skills folder (e.g., ~/.openclaw/skills/).
- Restart your agent or reload configuration.
- Invoke it using the filename (without extension) as the tool name, or through natural language if the description is clear.