8
n8n 中文网amn8n.com

使用RapidAPI提取YouTube频道元数据到Google Docs

中级

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

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "60c025075753afcab9f803964b4caaca9402f435deb4efafbb8e3b93b54d8752",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "73a62d48-7492-4ba2-bb94-c33382e9e561",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "webhookId": "2edc6cbb-9fb2-47c9-8387-8ff412c7838a",
      "parameters": {
        "options": {},
        "formTitle": "YouTube Channel Metadata ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "url",
              "placeholder": "Channel url",
              "requiredField": true
            }
          ]
        },
        "formDescription": "YouTube Channel Metadata"
      },
      "typeVersion": 2.2
    },
    {
      "id": "060b798e-25de-4acf-b563-c299ce006f81",
      "name": "重新格式化",
      "type": "n8n-nodes-base.code",
      "position": [
        460,
        0
      ],
      "parameters": {
        "jsCode": "// Get the first channel object from items array\nconst channel = $input.first().json.items[0];\n\nconst {\n  snippet,\n  statistics,\n  brandingSettings,\n} = channel;\n\nconst title = snippet.title || 'No title';\nconst description = snippet.description || 'No description available';\nconst customUrl = snippet.customUrl || 'No custom URL';\nconst publishedDate = new Date(snippet.publishedAt).toLocaleDateString();\nconst country = snippet.country || 'Not specified';\n\nconst subscriberCount = statistics.subscriberCount || '0';\nconst viewCount = statistics.viewCount || '0';\nconst videoCount = statistics.videoCount || '0';\n\nconst bannerUrl = brandingSettings.image?.bannerExternalUrl || 'No banner URL';\nconst keywords = brandingSettings.channel?.keywords || 'No keywords';\n\n// Prepare formatted string\nconst formatted = `\n📺 **Channel:** ${title}  \n🔗 **Custom URL:** https://youtube.com/${customUrl}  \n🗓️ **Published On:** ${publishedDate}  \n🌍 **Country:** ${country}\n\n👥 **Subscribers:** ${subscriberCount}  \n👁️ **Total Views:** ${viewCount}  \n🎥 **Total Videos:** ${videoCount}\n\n📝 **Description:**  \n${description}\n\n🏷️ **Keywords:** ${keywords}\n\n🖼️ **Banner Image:**  \n${bannerUrl}\n`;\n\n// Return formatted string\nreturn [\n  {\n    json: {\n      docContent: formatted.trim(),\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fca2fbf5-db93-4d05-8e70-c89f90edfaf0",
      "name": "在 Google Docs 中添加数据",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        720,
        0
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $json.docContent }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "Rt0RWApx8PL9t0RF",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "cff9cbb2-6fc4-4a66-a0b0-16dae3c1fd38",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -240
      ],
      "parameters": {
        "width": 520,
        "height": 1300,
        "content": "# **YouTube 频道元数据到 Google Docs**"
      },
      "typeVersion": 1
    },
    {
      "id": "2fa66d15-6311-44ff-820a-7bdf42d3b711",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -220
      ],
      "parameters": {
        "height": 360,
        "content": "**表单提交时**(表单触发器)"
      },
      "typeVersion": 1
    },
    {
      "id": "f6b5cf9b-4bb1-43cb-b0b9-90fa777d913a",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -260
      ],
      "parameters": {
        "height": 400,
        "content": "**YouTube 频道元数据**(HTTP 请求)"
      },
      "typeVersion": 1
    },
    {
      "id": "070451b2-9a0b-423b-bbd8-aa163d57178c",
      "name": "YouTube 频道元数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "https://youtube-metadata1.p.rapidapi.com/channel_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": "9d71eabf-7243-47ce-aa41-9ca2d8bcade4",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -260
      ],
      "parameters": {
        "height": 400,
        "content": "**重新格式化**(代码)"
      },
      "typeVersion": 1
    },
    {
      "id": "62b9f2a3-2ecc-4a50-979e-e0aaddb24f7c",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -260
      ],
      "parameters": {
        "height": 400,
        "content": "**在 Google Docs 中添加数据**(Google Docs)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Reformat": {
      "main": [
        [
          {
            "node": "Add Data in Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "YouTube Channel Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube Channel Metadata": {
      "main": [
        [
          {
            "node": "Reformat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流