{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "8107174c-5a28-4e08-be56-de75f9d85b01",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        300,
        0
      ],
      "parameters": {
        "url": "https://youtube-video-downloader-fast.p.rapidapi.com/download.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-video-downloader-fast.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "86a2db5e-5928-4459-ad69-846994ab98d0",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "formTitle": "YouTube To Mp4",
        "formFields": {
          "values": [
            {
              "fieldLabel": "URL",
              "requiredField": true
            }
          ]
        },
        "formDescription": "YouTube To Mp4"
      },
      "typeVersion": 2.2
    },
    {
      "id": "a183fdce-c385-4c17-b237-a0ac731adfc0",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        560,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0380d6fd-b5ab-49ef-a5e1-5d34a138f883",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.success }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c7806bea-3eaa-464e-8939-cd707de01ba4",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        800,
        -20
      ],
      "parameters": {
        "columns": {
          "value": {
            "Mp3": "={{ $json.medias[18].url }}",
            "Url": "={{ $json.url }}",
            "Mp4 720": "={{ $json.medias[3].url }}",
            "Mp4 1080": "={{ $json.medias[1].url }}",
            "Mp4 360p": "={{ $json.medias[0].url }}"
          },
          "schema": [
            {
              "id": "Url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Mp4 360p",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Mp4 360p",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Mp4 720",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Mp4 720",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Mp4 1080",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Mp4 1080",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Mp3",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Mp3",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1BFR7Ce8FYarGF7kvfaQf6fBsu7hLxDbzzp_RL8DDlas",
          "cachedResultUrl": "",
          "cachedResultName": "YT to Mp4"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "2c42910a-7192-41e4-91b6-921a42601bb9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -480
      ],
      "parameters": {
        "width": 740,
        "height": 740,
        "content": "# \ud83c\udfa5 YouTube to MP4 Downloader \n\nConvert YouTube videos into MP4 and MP3 formats automatically using **[YouTube Video Downloader API](https://rapidapi.com/skdeveloper/api/youtube-video-downloader-fast)**.  \nThis workflow fetches video download links, extracts multiple quality options, and logs results in Google Sheets.  \nIt\u2019s **fully customizable** \u2013 you can modify video qualities, add notifications, or integrate with different storage solutions.  \n\n---\n\n### \ud83d\udcdd **Node-by-Node Explanation**\n\n1. **On Form Submission** \u2192 Triggers when a user submits a YouTube video URL via a form. *(You can add more fields like format selection or email delivery.)*  \n2. **HTTP Request** \u2192 Sends a POST request to **YouTube Video Downloader API** to fetch downloadable links. *(You can switch the API endpoint or add extra headers easily.)*  \n3. **If Node** \u2192 Checks if the API response is successful before processing download links. *(You can add advanced conditions for custom validation.)*  \n4. **Google Sheets** \u2192 Appends video details including:  \n   - **Original URL**  \n   - **MP4 360p, 720p, 1080p links**  \n   - **MP3 link**  \n   *(You can add more resolutions or metadata fields like title, duration, size.)*  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "1fb4d9b5-c883-489b-9f05-0b851cd7b5b2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -200
      ],
      "parameters": {
        "height": 380,
        "content": "### 1\ufe0f\u20e3 **On Form Submission**  \n- Displays a form where the user enters the YouTube video URL.  \n- Acts as the starting trigger for the workflow. "
      },
      "typeVersion": 1
    },
    {
      "id": "a5d3d8eb-2202-4ccc-af42-aa51efd433aa",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -200
      ],
      "parameters": {
        "height": 380,
        "content": "### 2\ufe0f\u20e3 **HTTP Request**  \n- Sends the provided URL to **YouTube Video Downloader API** via RapidAPI.  \n- Retrieves different resolution MP4 and MP3 download links. "
      },
      "typeVersion": 1
    },
    {
      "id": "e572667f-8476-4aad-a72d-4ee99d191bcd",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -200
      ],
      "parameters": {
        "height": 380,
        "content": "### 3\ufe0f\u20e3 **If Node**  \n- Checks if the API request was successful.  \n- Ensures only valid results are processed for logging.  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "acc65470-0188-4d4c-a798-7862e98657cf",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        -200
      ],
      "parameters": {
        "height": 380,
        "content": "### 4\ufe0f\u20e3 **Google Sheets**  \n- Appends the original URL and all available download links (360p, 720p, 1080p, MP3) into a spreadsheet.  \n- Provides a structured history of all downloads for future reference.  \n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}