npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rolme/ytscript

v2.0.4

Published

A CLI tool to download YouTube transcripts and generate summaries

Readme

@rolme/ytscript

npm version License Build Status npm downloads node version

A powerful CLI tool and Node.js package for downloading and summarizing YouTube video transcripts using AI (ChatGPT and Claude).

Features

  • Download transcripts from YouTube videos
  • Generate AI-powered summaries using:
    • OpenAI's ChatGPT for concise, accurate summaries
    • Anthropic's Claude for detailed, nuanced analysis
  • Customize summary style (concise or detailed)
  • Control summary length and format
  • Support for multiple languages
  • Both CLI and programmatic usage
  • Flexible output options (console or file)

Installation

npm install @rolme/ytscript

CLI Usage

Download Transcript

# Basic usage
ytscript download https://youtube.com/watch?v=xxx

# Specify language
ytscript download https://youtube.com/watch?v=xxx -l es

# Custom output path
ytscript download https://youtube.com/watch?v=xxx -o transcript.txt

Summarize Transcript

# Basic usage with ChatGPT
ytscript summarize https://youtube.com/watch?v=xxx

# Use Claude with detailed summary style
ytscript summarize https://youtube.com/watch?v=xxx -p claude -s detailed

# ChatGPT with concise summary and max length
ytscript summarize https://youtube.com/watch?v=xxx -p chatgpt -s concise -m 500

# Save Claude summary to file with language preference
ytscript summarize https://youtube.com/watch?v=xxx -p claude -l en -o summary.txt

CLI Options

Download Command

  • -l, --language <code>: Language code (e.g., en, es, fr)
  • -o, --output <path>: Output file path
  • -f, --format <format>: Output format (text or json)

Summarize Command

  • -l, --language <code>: Language code (e.g., en, es, fr)
  • -o, --output <path>: Output file path
  • -p, --provider <n>: AI provider (chatgpt or claude)
  • -k, --api-key <key>: AI provider API key
  • -s, --style <style>: Summary style (concise or detailed)
  • -m, --max-length <number>: Maximum length of the summary
  • -f, --format <format>: Output format (text or json)

Output Formats

Text Format (Default)

The default text format outputs the transcript or summary directly to the console or file.

JSON Format

Using --format json outputs structured data in JSON format:

For download command:

{
  "videoId": "xxx",
  "title": "Video Title",
  "transcript": "Full transcript text",
  "segments": [
    {
      "text": "Segment text",
      "duration": 10.5,
      "offset": 0
    }
  ],
  "metadata": {
    "language": "en",
    "lastUpdated": "2024-03-14T12:00:00Z"
  }
}

For summarize command:

{
  "videoId": "xxx",
  "title": "Video Title",
  "transcript": "Original transcript",
  "summary": "AI-generated summary",
  "metadata": {
    "language": "en",
    "provider": "chatgpt",
    "style": "concise",
    "lastUpdated": "2024-03-14T12:00:00Z"
  }
}

Programmatic Usage

Basic Usage

import { getTranscript, summarizeVideo, OutputFormat } from "@rolme/ytscript";

// Download transcript with JSON output
const result = await getTranscript("https://youtube.com/watch?v=xxx", {
  format: OutputFormat.JSON,
});
console.log(result.transcript); // Access transcript text
console.log(result.segments); // Access transcript segments

// Summarize video with JSON output
const summary = await summarizeVideo("https://youtube.com/watch?v=xxx", {
  format: OutputFormat.JSON,
});
console.log(summary.transcript); // Original transcript
console.log(summary.summary); // AI-generated summary
console.log(summary.metadata); // Access metadata

Advanced Usage

// Configure summarization options
const result = await summarizeVideo("https://youtube.com/watch?v=xxx", {
  provider: "claude",
  apiKey: "your-api-key",
  language: "en",
  summary: {
    style: "detailed",
    maxLength: 1000,
  },
});

// Save transcript and summary to file
const filePath = await saveSummary("https://youtube.com/watch?v=xxx", {
  outputPath: "output.txt",
  provider: "chatgpt",
  summary: {
    style: "concise",
  },
});

API Keys

The package requires API keys for YouTube Data API and AI providers. Here's how to obtain them:

YouTube Data API Key

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the YouTube Data API v3:
    • Navigate to "APIs & Services" > "Library"
    • Search for "YouTube Data API v3"
    • Click "Enable"
  4. Create credentials:
    • Go to "APIs & Services" > "Credentials"
    • Click "Create Credentials" > "API Key"
  5. Set the API key in your environment:
    YOUTUBE_API_KEY=your-youtube-api-key

OpenAI API Key (for ChatGPT)

  1. Visit OpenAI's platform
  2. Sign up or log in to your account
  3. Go to "API Keys" section
  4. Click "Create new secret key"
  5. Set the API key in your environment:
    OPENAI_API_KEY=your-openai-key

Anthropic API Key (for Claude)

  1. Visit Anthropic's website
  2. Sign up for API access
  3. Once approved, get your API key from the dashboard
  4. Set the API key in your environment:
    ANTHROPIC_API_KEY=your-anthropic-key

You can store all API keys in a .env file:

# YouTube Data API v3 configuration
YOUTUBE_API_KEY=your-youtube-api-key

# AI Provider API Keys
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key

Note: Keep your API keys secure and never commit them to version control.

Error Handling

The package exports error types for specific handling:

import { TranscriptError, AIError } from "@rolme/ytscript";

try {
  const result = await summarizeVideo("https://youtube.com/watch?v=xxx");
} catch (error) {
  if (error instanceof TranscriptError) {
    console.error("Failed to fetch transcript:", error.message);
  } else if (error instanceof AIError) {
    console.error("AI summarization failed:", error.message);
  } else {
    console.error("Unknown error:", error);
  }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

AI Provider Features

ChatGPT (OpenAI)

  • Ideal for concise, to-the-point summaries
  • Great for technical content and factual accuracy
  • Supports multiple summary styles:
    • concise: Brief, focused summaries
    • detailed: Comprehensive analysis with key points

Claude (Anthropic)

  • Excellent for nuanced, contextual understanding
  • Strong at capturing subtle details and themes
  • Summary styles available:
    • concise: Clear, efficient summaries
    • detailed: In-depth analysis with context