youtube-transcripts

An n8n node for extracting YouTube video transcripts and subtitles using yt-dlp

Package Information

Released: 15 mo ago
Downloads: 11 weekly / 57 monthly
Latest Version: 1.0.4
Author: shrekai2025

Documentation

n8n-nodes-youtube-transcripts

一个用于提取 YouTube 视频字幕和转录的 n8n 自定义节点。

功能特点

  • 🎯 自动检测字幕:智能检测视频是否有可用字幕
  • 🌍 多语言支持:支持多种语言的字幕提取
  • 📝 多种格式:支持纯文本、SRT、VTT 格式输出
  • 🔧 基于 yt-dlp:使用强大的 yt-dlp 工具进行下载
  • ⚡ 简单易用:直接输入 YouTube URL 即可获取字幕

安装

前置条件

  1. 确保您的系统已安装 yt-dlp:
# 使用 pip 安装
pip install yt-dlp

# 或使用 Homebrew (macOS)
brew install yt-dlp

安装节点

npm install n8n-nodes-youtube-transcripts

使用方法

  1. 添加节点:在 n8n 工作流中添加 "YouTube Transcripts" 节点

  2. 配置参数:

    • YouTube URL: 输入要处理的 YouTube 视频链接
    • Language Priority: 设置语言优先级(如:zh,en,zh-CN)
    • Include Auto-Generated: 是否包含自动生成的字幕
    • Output Format: 选择输出格式(纯文本/SRT/VTT)
  3. 运行工作流:节点会自动检测字幕并返回结果

输出数据

成功时返回:

{
  "videoId": "视频ID",
  "title": "视频标题",
  "url": "原始URL",
  "transcript": "字幕内容",
  "format": "输出格式",
  "hasSubtitles": true
}

无字幕时返回:

{
  "error": "No subtitles available for this video",
  "hasSubtitles": false
}

配置选项

Language Priority

支持的语言代码示例:

  • zh - 中文
  • en - 英文
  • zh-CN - 简体中文
  • zh-TW - 繁体中文
  • ja - 日文
  • ko - 韩文

Output Format

  • Plain Text: 纯文本格式,去除时间戳
  • SRT: 标准 SubRip 格式,包含时间戳
  • VTT: WebVTT 格式,包含时间戳

错误处理

节点会处理以下错误情况:

  • 无效的 YouTube URL
  • 视频不存在或无法访问
  • 无可用字幕
  • yt-dlp 工具未安装

示例工作流

{
  "nodes": [
    {
      "name": "YouTube Transcripts",
      "type": "n8n-youtube-transcripts",
      "parameters": {
        "youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "languagePriority": "zh,en",
        "includeAutoGenerated": true,
        "outputFormat": "txt"
      }
    }
  ]
}

开发

构建项目

npm run build

开发模式

npm run dev

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

支持

如果您遇到问题或有建议,请:

  1. 查看 Issues
  2. 创建新的 Issue
  3. 或发送邮件至项目维护者

注意: 此工具仅用于合法的内容提取,请遵守相关法律法规和平台服务条款。

Discussion