8
n8n 中文网amn8n.com

YTB元数据生成器

高级

这是一个AI, Marketing领域的自动化工作流,包含 22 个节点。主要使用 If, Code, Wait, YouTube, HttpRequest 等节点,结合人工智能技术实现智能自动化。 生成YouTube视频元数据(时间戳、标签、描述等)

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "",
  "meta": {
    "instanceId": "",
    "templateCredsSetupCompleted": true
  },
  "name": "YTB元数据生成器",
  "tags": [],
  "nodes": [
    {
      "id": "",
      "name": "Mistral Cloud 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
      "position": [
        700,
        -40
      ],
      "parameters": {
        "model": "mistral-large-latest",
        "options": {}
      },
      "credentials": {
        "mistralCloudApi": {
          "id": "",
          "name": "Mistral Cloud account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "无操作,不执行任何操作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -440,
        120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        860,
        -40
      ],
      "parameters": {
        "jsonSchemaExample": "[\n  {\n    \"name\": \"preview\",\n    \"type\": \"string\",\n    \"description\": \"Short preview (100–200 characters, no hashtags)\"\n  },\n  {\n    \"name\": \"timestamps\",\n    \"type\": \"string\",\n    \"description\": \"YouTube-style timestamps, each on a new line, starts with 00:00\"\n  },\n  {\n    \"name\": \"tags\",\n    \"type\": \"string\",\n    \"description\": \"Comma-separated keywords (no hashtags)\"\n  }\n]\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "",
      "name": "无操作,不执行任何操作1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        700,
        100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "检查是否完成",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -160,
        -80
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/streamers~youtube-scraper/runs/last?token=[YOUR_API_TOKEN]",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "",
      "name": "获取数据集",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        -100
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/streamers~youtube-scraper/runs/last/dataset/items?token=[YOUR_API_TOKEN]",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "",
      "name": "抓取视频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -440,
        -80
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/streamers~youtube-scraper/runs?token=[YOUR_API_TOKEN]",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"downloadSubtitles\": true,\n    \"preferAutoGeneratedSubtitles\": false,\n    \"startUrls\": [\n        {\n            \"url\": \"{{ $('Trigger New Video Posted').item.json.link }}\",\n            \"method\": \"GET\"\n        }\n    ],\n    \"subtitlesLanguage\": \"en\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "",
      "name": "如果已完成",
      "type": "n8n-nodes-base.if",
      "position": [
        20,
        -80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "SUCCEEDED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        180,
        120
      ],
      "webhookId": "",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "",
      "name": "如果近期",
      "type": "n8n-nodes-base.if",
      "position": [
        -660,
        20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ new Date($json[\"pubDate\"]).getTime() }}",
              "rightValue": "={{ new Date().getTime() - 10 * 60 * 1000 }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "",
      "name": "如果未生成",
      "type": "n8n-nodes-base.if",
      "position": [
        460,
        -100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "",
              "operator": {
                "type": "string",
                "operation": "notContains"
              },
              "leftValue": "={{ $json.text }}",
              "rightValue": "00:00"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "",
      "name": "生成描述",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        700,
        -200
      ],
      "parameters": {
        "text": "You are given the full script of a YouTube video. Your task is to extract metadata in a structured format to be used in a YouTube upload.",
        "messages": {
          "messageValues": [
            {
              "type": "HumanMessagePromptTemplate",
              "message": "=Script Input:\n{{ $json.subtitles[0].srt }}\n\nFinal Output Format:\n\nPreview:\n[short preview description]\n\nTimestamps:\n00:00 [Title]\n00:30 [Title]\n...\n\nTags:\ntag1,tag2,tag3,...\n\nFollow these instructions strictly:\n\n1. Short Preview Description\nWrite a short preview (100–200 characters max) of the video.\nUse engaging language, and include relevant keywords from the topic of the video.\nThis should be a single sentence or two, no hashtags, no line breaks.\n\n2. Timestamps\nFormat: MM:SS Timestamp Title (each on a new line)\nMust start with 00:00\nEach timestamp section must be at least 30 seconds apart\nOnly 3 to 7 total timestamps\nEach timestamp title should be maximum 3 words, summarize the section clearly\nExample format:\n\"00:00 Intro  \n00:47 Key Concept  \n02:12 Real Example\"\n\n3. Tags\nProvide 5 to 10 relevant SEO-friendly keywords separated by commas\nNo hashtags\nFormat like this:\n\"automation,n8n,ai workflows,youtube growth,openai\"\n"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.5
    },
    {
      "id": "",
      "name": "格式化",
      "type": "n8n-nodes-base.code",
      "position": [
        1100,
        -200
      ],
      "parameters": {
        "jsCode": "// Assuming input data contains preview, timestamps, tags\nconst preview = $input.first().json.output[0].description;\nconst timestamps = $input.first().json.output[1].description;\n\n// Hardcoded links section (edit as needed)\nconst links = `\nLinks:\n- Website: https://example.com\n- Twitter: https://twitter.com/example\n- GitHub: https://github.com/example\n`;\n\n// Format description string\nconst description = preview + \"\\n\" +links + \"\\n\" +timestamps \n\n// Return the formatted description\nreturn [\n  {\n    json: {\n      description: description.trim(),\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -100
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 340,
        "content": "## 1- 输入"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -180
      ],
      "parameters": {
        "color": 7,
        "height": 480,
        "content": "## 2- 创建数据集"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -280
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 580,
        "content": "## 4- 检查并生成元数据"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -280
      ],
      "parameters": {
        "color": 7,
        "width": 460,
        "height": 240,
        "content": "## 5- 输出"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 500,
        "content": "## 3- 等待完成并获取数据集"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -800
      ],
      "parameters": {
        "color": 7,
        "width": 780,
        "height": 240,
        "content": "## 工作原理?"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -540
      ],
      "parameters": {
        "color": 7,
        "width": 780,
        "height": 340,
        "content": "## 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "触发新视频发布",
      "type": "n8n-nodes-base.rssFeedReadTrigger",
      "position": [
        -880,
        20
      ],
      "parameters": {
        "feedUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=[YOUR_CHANNEL_ID]",
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 10
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "更新YTB视频",
      "type": "n8n-nodes-base.youTube",
      "position": [
        1280,
        -200
      ],
      "parameters": {
        "title": "={{ $('Get DataSet').item.json.title }}",
        "videoId": "={{ $('Get DataSet').item.json.id }}",
        "resource": "video",
        "operation": "update",
        "regionCode": "US",
        "updateFields": {
          "tags": "={{ $('Generate Description').item.json.output[2].description }}",
          "description": "={{ $json.description }}"
        }
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "",
          "name": "YouTube account"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Check IF Finished",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format ": {
      "main": [
        [
          {
            "node": "Update YTB Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Recent": {
      "main": [
        [
          {
            "node": "Scrape Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get DataSet": {
      "main": [
        [
          {
            "node": "If Not Generated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Finished": {
      "main": [
        [
          {
            "node": "Get DataSet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Video": {
      "main": [
        [
          {
            "node": "Check IF Finished",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Not Generated": {
      "main": [
        [
          {
            "node": "Generate Description",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check IF Finished": {
      "main": [
        [
          {
            "node": "If Finished",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Description": {
      "main": [
        [
          {
            "node": "Format ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Cloud Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Description",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Description",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Trigger New Video Posted": {
      "main": [
        [
          {
            "node": "If Recent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 人工智能, 营销

需要付费吗?

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

工作流信息
难度等级
高级
节点数量22
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Nasser

Nasser

@nasser

Data Engineer, now automating processes mostly with n8n, Make and code

外部链接
在 n8n.io 查看

分享此工作流