JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q56794F
  • License MIT

A CLI tool to download YouTube video transcripts

Package Exports

  • @rolme/ytscript
  • @rolme/ytscript/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rolme/ytscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ytscript

CI npm version License: MIT TypeScript

A CLI tool to download YouTube video transcripts with automatic video title-based filenames. Use it as a CLI tool or import it into your project.

Installation

# Install globally for CLI usage
npm install -g @rolme/ytscript

# Install as a dependency in your project
npm install @rolme/ytscript

CLI Usage

# Basic usage - saves transcript with video title as filename
ytscript https://www.youtube.com/watch?v=VIDEO_ID

# Specify language
ytscript https://www.youtube.com/watch?v=VIDEO_ID -l en

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

API Usage

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

// Get transcript text and segments
const result = await getTranscript("https://www.youtube.com/watch?v=VIDEO_ID", {
  language: "en", // optional
});
console.log(result.transcript); // Clean, formatted transcript text
console.log(result.videoId); // Video ID for additional operations

// Save transcript to file (uses video title as filename by default)
const outputPath = await saveTranscript(
  "https://www.youtube.com/watch?v=VIDEO_ID",
  {
    language: "en", // optional
    outputPath: "transcript.txt", // optional, overrides title-based filename
  }
);
console.log(`Saved to: ${outputPath}`);

Features

  • Automatic video title-based filenames
  • Clean, formatted transcript text (HTML entities are properly decoded)
  • Support for multiple languages
  • TypeScript support
  • Both CLI and programmatic usage
  • Custom output path option

Options

  • language: Language code (e.g., 'en', 'es', 'fr')
  • outputPath: Custom file path for saving the transcript. If not provided, uses {video-title}-{timestamp}.txt

Output Format

By default, transcripts are saved as:

  • Filename: {video-title}-{timestamp}.txt (e.g., build-ai-agents-that-evolve-over-time-2025-03-14T20-13-59-980Z.txt)
  • Content: Clean text with proper formatting and decoded HTML entities

Development

# Install dependencies
npm install

# Run tests
npm test

# Run linter
npm run lint

# Build the project
npm run build

# Start the CLI tool locally
npm start

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT