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
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/ytscriptCLI 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.txtAPI 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 startContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT