8
n8n 中文网amn8n.com

使用RapidAPI、Google Drive存储和Sheets日志记录将YouTube视频转换为MP3

高级

这是一个File Management领域的自动化工作流,包含 19 个节点。主要使用 If, Code, Wait, FormTrigger, GoogleDrive 等节点。 使用RapidAPI、Google Drive存储和Sheets日志记录将YouTube视频转换为MP3

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "60c025075753afcab9f803964b4caaca9402f435deb4efafbb8e3b93b54d8752",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "85bb7486-da1a-4dcd-979d-819d435ab2e0",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -500,
        -20
      ],
      "webhookId": "5fac25c4-863c-4b9f-a1ed-bbccce99a8fd",
      "parameters": {
        "options": {},
        "formTitle": "Youtube to MP3",
        "formFields": {
          "values": [
            {
              "fieldLabel": "URL",
              "placeholder": "https://youtu.be/abcdefg",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Youtube to MP3 Converter"
      },
      "typeVersion": 2.2
    },
    {
      "id": "90b93ccf-0eec-4a9e-82b8-c2974e590353",
      "name": "HTTP请求",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -280,
        -20
      ],
      "parameters": {
        "url": "https://youtube-to-mp3-downloader1.p.rapidapi.com/output.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-to-mp3-downloader1.p.rapidapi.co"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "035ea1e7-c4e6-446e-8e70-0944e1e62156",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        580,
        -340
      ],
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "id",
          "value": "1MH4rVD9lziY-acugKQFoitbE6Gv5vdLl"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1MH4rVD9lziY-acugKQFoitbE6Gv5vdLl",
          "cachedResultUrl": "",
          "cachedResultName": "youtube to mp3"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "qEkQ8MFn0uSHgAqY",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "9c713a2f-c2c5-43a7-aeec-409682233334",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1200,
        -140
      ],
      "parameters": {
        "columns": {
          "value": {
            "URL": "={{ $('On form submission').item.json.URL }}",
            "Size": "={{ $('Code').item.json.fileSizeInMb }} MB",
            "Status": "Success",
            "Created at": "={{ $now.format('dd-MM-yyyy') }}",
            "Download Link": "={{ $('Google Drive').item.json.webContentLink }}",
            "Web View Link": "={{ $('Google Drive').item.json.webViewLink }}"
          },
          "schema": [
            {
              "id": "URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Download Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Download Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Web View Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Web View Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Size",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Size",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1S1KYpKzOEGw8eesZtAY03Uf8WXRKKWXkmUvXsNdsy0U"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "8aebafbf-69d8-476a-97f4-62d0122fa818",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        720,
        220
      ],
      "parameters": {
        "columns": {
          "value": {
            "URL": "={{ $('On form submission').item.json.URL }}",
            "Size": "=N/A",
            "Status": "={{ $json.status }}",
            "Created at": "={{ $now.format('dd-MM-yyyy') }}",
            "Download Link": "N/A",
            "Web View Link": "=N/A"
          },
          "schema": [
            {
              "id": "URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Download Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Download Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Web View Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Web View Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Size",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Size",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1S1KYpKzOEGw8eesZtAY03Uf8WXRKKWXkmUvXsNdsy0U"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "076854cf-088b-4227-847e-be673d3e2cd5",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        0,
        -20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e2308413-5c68-4e33-ae0a-c0c0b2d62669",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "=done"
            },
            {
              "id": "bcc58e3d-9609-4ec3-adb9-bc6098205818",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ba810d66-e827-48a4-a72d-a94dd0c3e20b",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        260,
        220
      ],
      "webhookId": "fabd97e2-2cec-4bca-a2cf-cf6c6b0720d5",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "9db89edc-1c9c-4678-9261-23397f2ad5b1",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        -280
      ],
      "parameters": {
        "jsCode": "function kbToMb(kb) {\n    return (kb / 1024).toFixed(2); // Convert KB to MB\n}\n\nfunction bytesToKb(bytes) {\n    return bytes / 1024;  // Convert Bytes to KB\n}\n\n// Get the file size in bytes from the input (from the Google Drive node)\nlet fileSizeInBytes = $input.first().json.size;\n\n// Convert bytes to KB first\nlet fileSizeInKb = bytesToKb(fileSizeInBytes);\n\n// Then convert KB to MB\nlet fileSizeInMb = kbToMb(fileSizeInKb);\n\nlet outputData = {\n    fileName: $input.first().json.name,\n    fileSizeInMb: fileSizeInMb\n};\n\n// Return an array containing the output data\nreturn [{ json: outputData }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a5fb5ed7-bd31-40d1-b4f7-8e7f4b0dd869",
      "name": "下载 mp3",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        280,
        -340
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "8fb7d07e-37a2-4fd9-8a40-af03e14cdbb8",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        -420
      ],
      "parameters": {
        "width": 660,
        "height": 1160,
        "content": "# **YouTube 转 MP3 转换器**"
      },
      "typeVersion": 1
    },
    {
      "id": "b9831f59-f02a-4f44-82c5-0237146c6180",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -180
      ],
      "parameters": {
        "height": 320,
        "content": "**表单提交时**"
      },
      "typeVersion": 1
    },
    {
      "id": "76930924-5f65-4219-9170-e927e3dd0e15",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        -480
      ],
      "parameters": {
        "height": 620,
        "content": "**HTTP 请求**"
      },
      "typeVersion": 1
    },
    {
      "id": "64ac5edf-deec-4228-8c57-0fd93b3416e2",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -180
      ],
      "parameters": {
        "height": 320,
        "content": "**条件判断**"
      },
      "typeVersion": 1
    },
    {
      "id": "92097d91-1648-4e93-a7cf-2d7b6329d8f7",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -460
      ],
      "parameters": {
        "height": 300,
        "content": "**下载 mp3**"
      },
      "typeVersion": 1
    },
    {
      "id": "66c2544b-672e-4823-b33d-b9605cfd1306",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        520,
        -440
      ],
      "parameters": {
        "height": 260,
        "content": "**Google 云端硬盘**"
      },
      "typeVersion": 1
    },
    {
      "id": "4ac295fe-8b12-4e7e-bbfc-9644397bf7c4",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        -420
      ],
      "parameters": {
        "height": 260,
        "content": "**代码**"
      },
      "typeVersion": 1
    },
    {
      "id": "8da832b5-3c4b-4687-84f0-15a6a960da9a",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -260
      ],
      "parameters": {
        "height": 260,
        "content": "**Google 表格**"
      },
      "typeVersion": 1
    },
    {
      "id": "8517413c-868a-490c-b31d-8a002dc821df",
      "name": "GET 模型",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        60
      ],
      "parameters": {
        "height": 280,
        "content": "**Google 表格1**"
      },
      "typeVersion": 1
    },
    {
      "id": "190cb65d-fbe1-4019-a0a1-60c6afa8b132",
      "name": "## 1. 创建新的自定义 OpenAI 凭据",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**等待**"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Download mp3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download mp3": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文件管理

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流