8
n8n 中文网amn8n.com

使用RapidAPI提取YouTube视频元数据并保存到Google Docs

中级

这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 9 个节点。主要使用 Code, GoogleDocs, FormTrigger, HttpRequest 等节点。 使用RapidAPI提取YouTube视频元数据并保存到Google Docs

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "60c025075753afcab9f803964b4caaca9402f435deb4efafbb8e3b93b54d8752"
  },
  "nodes": [
    {
      "id": "2d304223-ef2d-4e03-814d-cac411106f6b",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -160,
        220
      ],
      "webhookId": "2edc6cbb-9fb2-47c9-8387-8ff412c7838a",
      "parameters": {
        "options": {},
        "formTitle": "YouTube Metadata ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "url",
              "requiredField": true
            }
          ]
        },
        "formDescription": "YouTube Metadata"
      },
      "typeVersion": 2.2
    },
    {
      "id": "3ddda565-879e-4685-bde6-e3f1dc62df2e",
      "name": "YouTube 元数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        60,
        220
      ],
      "parameters": {
        "url": "https://youtube-metadata1.p.rapidapi.com/video_metadata.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.url }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "youtube-metadata1.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9ddd4dd3-3c23-471a-aac9-9222deb584a5",
      "name": "重新格式化",
      "type": "n8n-nodes-base.code",
      "position": [
        300,
        220
      ],
      "parameters": {
        "jsCode": "const itemsArray = $input.first().json.items;\n\n// Safely access the first video item\nconst video = itemsArray[0];\nconst {\n  id: videoId,\n  snippet,\n  contentDetails,\n  statistics,\n} = video;\n\n// Format tags as a comma-separated string\nconst tags = snippet.tags && snippet.tags.length > 0\n  ? snippet.tags.join(', ')\n  : 'No tags available';\n\n// Format published date\nconst publishedDate = new Date(snippet.publishedAt).toLocaleDateString();\n\n// Format duration (optional: still in ISO 8601 like PT4M16S)\nconst duration = contentDetails.duration;\n\n// Prepare formatted content\nconst formatted = `\n🎬 **${snippet.title}**\n\n🧾 **Description:**\n${snippet.description}\n\n📺 **Channel:** ${snippet.channelTitle}\n📅 **Published At:** ${publishedDate}\n\n📊 **Stats:**\n- Views: ${statistics.viewCount}\n- Likes: ${statistics.likeCount}\n- Comments: ${statistics.commentCount}\n\n🕒 **Duration:** ${duration}\n\n🏷️ **Tags:** ${tags}\n\n🔗 **Video URL:** https://www.youtube.com/watch?v=${videoId}\n🖼️ **Thumbnail:** ${snippet.thumbnails.high.url}\n`;\n\n// Return formatted string for use in Google Docs\nreturn [\n  {\n    json: {\n      docContent: formatted.trim()\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0589461b-0419-4798-9f69-851d7d9fffb3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -40
      ],
      "parameters": {
        "width": 520,
        "height": 500,
        "content": "自动化 YouTube 视频元数据提取与文档记录工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "6d94b502-69ea-41a5-a4df-22fe20ee812b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**表单提交时:**"
      },
      "typeVersion": 1
    },
    {
      "id": "656ff1b1-f872-48d8-80c8-dd8df82d1ebc",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**YouTube 元数据(HTTP 请求):**"
      },
      "typeVersion": 1
    },
    {
      "id": "73b16e7c-f9ac-46e7-83dc-902ebbd74158",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**重新格式化(代码):**"
      },
      "typeVersion": 1
    },
    {
      "id": "bccb9237-7414-4976-9b60-5504c4d3cc7d",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        520,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**在 Google Sheet 中追加数据:**"
      },
      "typeVersion": 1
    },
    {
      "id": "ee750cf2-1839-469d-8a84-dff68f280535",
      "name": "在 Google Docs 中追加数据",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        560,
        220
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $json.docContent }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "Rt0RWApx8PL9t0RF",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    }
  ],
  "pinData": {},
  "connections": {
    "Reformat": {
      "main": [
        [
          {
            "node": "Append Data in Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube Metadata": {
      "main": [
        [
          {
            "node": "Reformat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "YouTube Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 杂项, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量9
分类2
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流