8
n8n 中文网amn8n.com

使用DeepL自动翻译YouTube视频为日语并发布到Slack

高级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 20 个节点。主要使用 If, Code, DeepL, Merge, Slack 等节点。 使用DeepL自动翻译YouTube视频为日语并发布到Slack

前置要求
  • Slack Bot Token 或 Webhook URL
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "iNkDWkBewhVKUVWf",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 DeepL 自动翻译 YouTube 视频为日语并发布到 Slack",
  "tags": [],
  "nodes": [
    {
      "id": "8908066f-105b-4a8c-a642-921c10e16d25",
      "name": "RSS 触发器",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        -128,
        -160
      ],
      "parameters": {
        "url": "https://www.youtube.com/feeds/videos.xml?channel_id=UCYO_jab_esuFRV4b17AJtAw",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "23e0fa4a-a16e-4e11-b9b5-879c1001f324",
      "name": "发送到 Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        1616,
        -256
      ],
      "parameters": {
        "text": "=🎥 *New YouTube Video!*  \n━━━━━━━━━━━━━━━  \n📌 *タイトル*  \n{{ $json.title }}\n\n📝 *説明*  \n{{ $json.description }}\n\n🌍 *Original Title*  \n{{ $('Merge YouTube + DeepL Results1').item.json.title }}\n\n🗒️ *Original Description*  \n{{ $('Merge YouTube + DeepL Results1').item.json.description }}\n\n🔗 *Link*  \n<{{ $('Format YouTube Data for DeepL').item.json.link }}|Watch on YouTube>",
        "channel": "=#general",
        "attachments": [],
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "2kyw7TSL5VT4S3md",
          "name": "Slack account 8"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ebff7150-ee6d-4dad-ad03-a29944fcf28a",
      "name": "获取视频",
      "type": "n8n-nodes-base.youTube",
      "position": [
        496,
        -256
      ],
      "parameters": {
        "part": [
          "snippet"
        ],
        "options": {},
        "videoId": "={{ String($json.YT_CHANNEL_ID || $json.id || $json.link || '')\n    .replace(/^yt:video:/,'')\n    .replace(/^.*(?:v=|shorts\\/|youtu\\.be\\/)/,'')\n    .split(/[?&]/)[0] }}",
        "resource": "video",
        "operation": "get"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "CMyE0HrVEaStWZgG",
          "name": "YouTube account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a461efd7-0ffc-4a56-b270-a064b0a91d3e",
      "name": "发送消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        496,
        -64
      ],
      "webhookId": "8c1cfac1-12a9-4ef9-9b98-5fa9b8504772",
      "parameters": {
        "text": "= *スキップされた動画を検出しました* 📺 タイトル: {{$json.title || $json.snippet.title}} 🔗 URL: {{$json.link || `https://www.youtube.com/watch?v=${$json.id}`}} ⚠️ 理由: 英語タイトルではないため、翻訳対象外としました",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "CKUCBTG0H",
          "cachedResultName": "general"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "2kyw7TSL5VT4S3md",
          "name": "Slack account 8"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "bfd54f44-77e7-4ba0-a523-e6cd2b8d432f",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -592
      ],
      "parameters": {
        "width": 432,
        "height": 1232,
        "content": "## 概述"
      },
      "typeVersion": 1
    },
    {
      "id": "dd5f0eef-4159-40db-a27d-02f318ea467a",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        112
      ],
      "parameters": {
        "color": 7,
        "height": 304,
        "content": "## 发送消息(已跳过)"
      },
      "typeVersion": 1
    },
    {
      "id": "988d0c76-7f0c-4992-bae8-f3bb51369203",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 288,
        "content": "## 为 DeepL 格式化 YouTube 数据"
      },
      "typeVersion": 1
    },
    {
      "id": "f790cfce-8057-4636-baee-7dc5939c045b",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -368
      ],
      "parameters": {
        "color": 7,
        "height": 192,
        "content": "## 语言过滤器"
      },
      "typeVersion": 1
    },
    {
      "id": "81f79bc3-f47d-4e9d-81d1-cd3bc0255351",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 224,
        "content": "## RSS 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "85c85131-fbd2-4345-a74c-1caf63f8d270",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        -64
      ],
      "parameters": {
        "color": 7,
        "height": 208,
        "content": "## 合并"
      },
      "typeVersion": 1
    },
    {
      "id": "f20df73e-1c72-4847-9a03-8488349b73a5",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        -512
      ],
      "parameters": {
        "color": 7,
        "height": 272,
        "content": "## 使用 DeepL 翻译"
      },
      "typeVersion": 1
    },
    {
      "id": "8194a237-a490-4354-bb0e-9fe885ac6824",
      "name": "### 替换 Airtable 连接",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -480
      ],
      "parameters": {
        "color": 7,
        "height": 192,
        "content": "## 获取视频"
      },
      "typeVersion": 1
    },
    {
      "id": "6b5e5ef1-b928-43fb-aab7-64b2414c3ea0",
      "name": "语言过滤器",
      "type": "n8n-nodes-base.if",
      "position": [
        272,
        -160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "00af14f6-2d40-4fb3-bdb1-a16438529179",
              "operator": {
                "type": "string",
                "operation": "regex"
              },
              "leftValue": "={{ String($('RSS Trigger').item.json?.title ?? '') }}",
              "rightValue": "^[A-Za-z0-9\\s\\W]+$"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "239c591d-0625-4257-8f27-1c087058736f",
      "name": "为 DeepL 格式化 YouTube 数据",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        -256
      ],
      "parameters": {
        "jsCode": "// --- YouTubeデータの取得 ---\nconst item = $json;\n\n// RSS からは title / link だけ、YouTubeノードからは snippet 構造を想定\nconst title = item.snippet?.title || item.title || \"No title\";\nconst description = item.snippet?.description || item.description || \"No description\";\nconst videoId = item.id?.videoId || item.id?.replace(\"yt:video:\", \"\") || \"unknown\";\nconst link = item.link || `https://www.youtube.com/watch?v=${videoId}`;\n\n// --- 整形(DeepLに渡す形) ---\nconst textToTranslate = `\n【Title】\n${title}\n\n【Description】\n${description}\n`;\n\n// --- DeepLに渡すJSON形式で出力 ---\nreturn [\n  {\n    json: {\n      title,\n      description,\n      videoId,\n      link,\n      textToTranslate,\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "468941d1-78ab-4a00-a539-d86b81c2c7c7",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        -480
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 352,
        "content": "## 设置清单"
      },
      "typeVersion": 1
    },
    {
      "id": "c2cc4803-9017-4fef-82ad-b1023eace6d6",
      "name": "翻译语言",
      "type": "n8n-nodes-base.deepL",
      "position": [
        944,
        -192
      ],
      "parameters": {
        "text": "={{ $json.textToTranslate }}",
        "translateTo": "JA",
        "additionalFields": {}
      },
      "credentials": {
        "deepLApi": {
          "id": "BzWijzgd9hLwECP0",
          "name": "DeepL account 4"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "494aff32-6c93-4623-bc66-0138e5cf0694",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1648,
        -48
      ],
      "parameters": {
        "color": 7,
        "height": 192,
        "content": "## 发送到 Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "a0179356-9df6-4628-aee6-418cda343144",
      "name": "合并 YouTube + DeepL 结果1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1168,
        -256
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "63f64775-51e9-4e31-aa66-8662a9f2f6dc",
      "name": "格式化翻译输出",
      "type": "n8n-nodes-base.code",
      "position": [
        1392,
        -256
      ],
      "parameters": {
        "jsCode": "// 入力データ取得\nconst text = $json.text || '';\n\n// タイトル行を抽出\nconst titleMatch = text.match(/タイトル[^\\n]*\\n(.*?)\\n/);\nconst title = titleMatch ? titleMatch[1].trim() : '';\n\n// 説明行を抽出\nconst descMatch = text.match(/説明[^\\n]*\\n([\\s\\S]*)/);\nconst description = descMatch ? descMatch[1].trim() : '';\n\n// Slackで見やすいように成形\nreturn {\n  json: {\n    title,\n    description\n  }\n};\n"
      },
      "typeVersion": 2
    },
    {
      "id": "24384f42-e32b-4ec0-b5de-66c754faa639",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        -704
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 416,
        "content": "## 格式化翻译输出"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dc7904c4-4ad8-43fe-a3a4-87b66973cf02",
  "connections": {
    "Get a video": {
      "main": [
        [
          {
            "node": "Format YouTube Data for DeepL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Trigger": {
      "main": [
        [
          {
            "node": "Language Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Language Filter": {
      "main": [
        [
          {
            "node": "Get a video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate a language": {
      "main": [
        [
          {
            "node": "Merge YouTube + DeepL Results1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Translated Output": {
      "main": [
        [
          {
            "node": "Send to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format YouTube Data for DeepL": {
      "main": [
        [
          {
            "node": "Translate a language",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge YouTube + DeepL Results1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge YouTube + DeepL Results1": {
      "main": [
        [
          {
            "node": "Format Translated Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 社交媒体, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流