{
  "nodes": [
    {
      "id": "2d304223-ef2d-4e03-814d-cac411106f6b",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -160,
        220
      ],
      "parameters": {
        "options": {},
        "formTitle": "YouTube Metadata ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "url",
              "requiredField": true
            }
          ]
        },
        "formDescription": "YouTube Metadata"
      },
      "typeVersion": 2.2
    },
    {
      "id": "3ddda565-879e-4685-bde6-e3f1dc62df2e",
      "name": "YouTube Metadata",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        60,
        220
      ],
      "parameters": {
        "url": "https://youtube-metadata1.p.rapidapi.com/video_metadata.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-metadata1.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9ddd4dd3-3c23-471a-aac9-9222deb584a5",
      "name": "Reformat",
      "type": "n8n-nodes-base.code",
      "position": [
        300,
        220
      ],
      "parameters": {
        "jsCode": "const itemsArray = $input.first().json.items;\n\n// Safely access the first video item\nconst video = itemsArray[0];\nconst {\n  id: videoId,\n  snippet,\n  contentDetails,\n  statistics,\n} = video;\n\n// Format tags as a comma-separated string\nconst tags = snippet.tags && snippet.tags.length > 0\n  ? snippet.tags.join(', ')\n  : 'No tags available';\n\n// Format published date\nconst publishedDate = new Date(snippet.publishedAt).toLocaleDateString();\n\n// Format duration (optional: still in ISO 8601 like PT4M16S)\nconst duration = contentDetails.duration;\n\n// Prepare formatted content\nconst formatted = `\n\ud83c\udfac **${snippet.title}**\n\n\ud83e\uddfe **Description:**\n${snippet.description}\n\n\ud83d\udcfa **Channel:** ${snippet.channelTitle}\n\ud83d\udcc5 **Published At:** ${publishedDate}\n\n\ud83d\udcca **Stats:**\n- Views: ${statistics.viewCount}\n- Likes: ${statistics.likeCount}\n- Comments: ${statistics.commentCount}\n\n\ud83d\udd52 **Duration:** ${duration}\n\n\ud83c\udff7\ufe0f **Tags:** ${tags}\n\n\ud83d\udd17 **Video URL:** https://www.youtube.com/watch?v=${videoId}\n\ud83d\uddbc\ufe0f **Thumbnail:** ${snippet.thumbnails.high.url}\n`;\n\n// Return formatted string for use in Google Docs\nreturn [\n  {\n    json: {\n      docContent: formatted.trim()\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0589461b-0419-4798-9f69-851d7d9fffb3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -40
      ],
      "parameters": {
        "width": 520,
        "height": 500,
        "content": " \nAutomated YouTube Video Metadata Extraction and Documentation Workflow\n\n**Description:**  \nEasily extract detailed YouTube video metadata from any URL and automatically format and save it to Google Docs for streamlined documentation and analysis.\n\n- **On form submission:**  \n  Triggers the workflow when a user submits a YouTube URL via the form.\n\n- **YouTube Metadata (HTTP Request):**  \n  Sends the submitted URL to the RapidAPI YouTube Metadata service to fetch detailed video data.\n\n- **Reformat (Code):**  \n  Extracts and formats key video details like title, description, stats, and thumbnails into a clean, readable string.\n\n- **Append Data in Google Docs:**  \n  Inserts the formatted video metadata into a specified Google Docs document for storage or further use.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6d94b502-69ea-41a5-a4df-22fe20ee812b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**On form submission:**  \n  Triggers the workflow when a user submits a YouTube URL via the form."
      },
      "typeVersion": 1
    },
    {
      "id": "656ff1b1-f872-48d8-80c8-dd8df82d1ebc",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        120
      ],
      "parameters": {
        "height": 240,
        "content": " **YouTube Metadata (HTTP Request):**  \n  Sends the submitted URL to the RapidAPI YouTube Metadata service to fetch detailed video data.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "73b16e7c-f9ac-46e7-83dc-902ebbd74158",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**Reformat (Code):**  \n  Extracts and formats key video details like title, description, stats, and thumbnails into a clean, readable string.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "bccb9237-7414-4976-9b60-5504c4d3cc7d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        520,
        120
      ],
      "parameters": {
        "height": 240,
        "content": "**Append Data In Google Sheet:**  \n  Append Data in Google sheet for the future usages.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ee750cf2-1839-469d-8a84-dff68f280535",
      "name": "Append Data in Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        560,
        220
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $json.docContent }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    }
  ],
  "connections": {
    "Reformat": {
      "main": [
        [
          {
            "node": "Append Data in Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube Metadata": {
      "main": [
        [
          {
            "node": "Reformat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "YouTube Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}