8
n8n 中文网amn8n.com

将特定 YouTube 频道最热门的视频添加到表格中

中级

这是一个Market Research领域的自动化工作流,包含 11 个节点。主要使用 SplitOut, HttpRequest, GoogleSheets, ManualTrigger 等节点。 按观看次数追踪 YouTube 热门视频,同步至 Google Sheets

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "M0TnkjeDHSBlsVLQ",
  "meta": {
    "instanceId": "1995ed9acdcea54e44032fa9fdaaa756a5f5932c630ba083376b6895162377f6",
    "templateCredsSetupCompleted": true
  },
  "name": "将特定 YouTube 频道最热门的视频添加到表格中",
  "tags": [],
  "nodes": [
    {
      "id": "038873e2-0e74-4644-be10-b485c1e40d81",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -160,
        60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1a8d863a-8c74-4f94-9adf-503ca37ad584",
      "name": "通过 YouTube API 获取观看次数最多的视频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        300,
        40
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/search",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "YOUR_YOUTUBE_API_KEY"
            },
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "channelId",
              "value": "={{ $json.ChannelID }}"
            },
            {
              "name": "maxResults",
              "value": "={{ $json.video_num_to_get }}"
            },
            {
              "name": "order",
              "value": "viewCount"
            },
            {
              "name": "type",
              "value": "video"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "69553f6a-c563-4389-9618-3b402e497e3b",
      "name": "从表格中读取频道信息",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        80,
        40
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "6b51fd78-6868-41a6-90de-fb7ba05db9cc",
      "name": "拆分为单个视频",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        520,
        40
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "5fa2c6ec-6b92-4ba4-9ab6-37718d3354af",
      "name": "将视频详情追加到表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        740,
        40
      ],
      "parameters": {
        "columns": {
          "value": {
            "title": "={{ $json.items.snippet.title }}",
            "videoId": "={{ $json.items.id.videoId }}",
            "videoLink": "=https://www.youtube.com/watch?v={{ $json.items.id.videoId }}",
            "channelName": "={{ $json.items.snippet.channelTitle }}"
          },
          "schema": [
            {
              "id": "channelName",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "channelName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoLink",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_OUTPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a494ab3e-f3ba-446c-a7b9-c347c34d9cc8",
      "name": "设置说明与指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -220
      ],
      "parameters": {
        "content": "## 这是注释"
      },
      "typeVersion": 1
    },
    {
      "id": "43af9899-b3cb-4300-8bbd-38142457b3fa",
      "name": "通过 YouTube API 获取观看次数最多的视频1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1820,
        760
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/search",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "YOUR_YOUTUBE_API_KEY"
            },
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "channelId",
              "value": "={{ $json.ChannelID }}"
            },
            {
              "name": "maxResults",
              "value": "={{ $json.video_num_to_get }}"
            },
            {
              "name": "order",
              "value": "viewCount"
            },
            {
              "name": "type",
              "value": "video"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b9efce22-129d-4971-a6d5-ddc1a46757b3",
      "name": "从表格中读取频道信息1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1600,
        760
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "edc478de-26a7-4a2e-be8e-fa7a47b3da30",
      "name": "拆分为单个视频1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2040,
        760
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "81ec042b-6a6c-48af-8b68-03c90366c87c",
      "name": "将视频详情追加到表格1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2260,
        760
      ],
      "parameters": {
        "columns": {
          "value": {
            "title": "={{ $json.items.snippet.title }}",
            "videoId": "={{ $json.items.id.videoId }}",
            "videoLink": "=https://www.youtube.com/watch?v={{ $json.items.id.videoId }}",
            "channelName": "={{ $json.items.snippet.channelTitle }}"
          },
          "schema": [
            {
              "id": "channelName",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "channelName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoLink",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_OUTPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "178043b9-528c-45bc-956c-98663bad69b2",
      "name": "设置说明与指南1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        500
      ],
      "parameters": {
        "width": 500,
        "height": 1460,
        "content": "## 工作流设置指南"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f642b6b7-f174-4ea0-9e8c-ad033597d947",
  "connections": {
    "Read Channel Info from Sheet": {
      "main": [
        [
          {
            "node": "Fetch Most-Viewed Videos via YouTube API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Into Individual Videos": {
      "main": [
        [
          {
            "node": "Append Video Details to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Channel Info from Sheet1": {
      "main": [
        [
          {
            "node": "Fetch Most-Viewed Videos via YouTube API1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Into Individual Videos1": {
      "main": [
        [
          {
            "node": "Append Video Details to Sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Read Channel Info from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Most-Viewed Videos via YouTube API": {
      "main": [
        [
          {
            "node": "Split Into Individual Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Most-Viewed Videos via YouTube API1": {
      "main": [
        [
          {
            "node": "Split Into Individual Videos1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流