{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "b0b64125-4241-45bb-8368-bc5b28d795af",
      "name": "Main \u2014 Overview & Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -208
      ],
      "parameters": {
        "width": 400,
        "height": 764,
        "content": "## Influencer Content Repurposing Pipeline\nAutomatically extract viral short clips from any long influencer video using WayinVideo AI, then save each clip to Google Drive.\n\n### How it works\n1. Submit a video URL, brand name, and clip count via the web form.\n2. The workflow calls WayinVideo API to start an AI clipping task.\n3. It waits 45 seconds, then polls for results.\n4. If clips are ready, each is downloaded and uploaded to Google Drive. If not ready, it waits and retries.\n\n### Setup\n1. Replace **YOUR_WAYINVIDEO_API_KEY** in nodes \"2. WayinVideo \u2014 Submit Clipping Task\" and \"4. WayinVideo \u2014 Poll Clips Result\".\n2. Connect your Google account in node \"8. Google Drive \u2014 Upload Clip\" via OAuth2.\n3. Set your Google Drive folder ID in node \"8. Google Drive \u2014 Upload Clip\".\n4. Optionally adjust clip duration, resolution or ratio in the Submit node.\n\n### Customization tips\n- Change `target_duration` to `DURATION_15_30` for shorter TikTok clips.\n- Add a Slack or email node after upload to notify your team.\n- Log clip metadata (title, score, tags) to Google Sheets after upload."
      },
      "typeVersion": 1
    },
    {
      "id": "70949577-4160-42cb-b1f8-0189af0f6f45",
      "name": "Section \u2014 Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 116,
        "content": "## 1. Input\nUser submits a video URL, brand name, and how many clips to generate via a web form."
      },
      "typeVersion": 1
    },
    {
      "id": "5aa7ed4b-7b17-404c-a963-a9e9eadd1161",
      "name": "Section \u2014 API Submission",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        -96
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 356,
        "content": "## 2. WayinVideo API Submission\nSends the video to WayinVideo for AI clipping. Returns a task ID used for polling."
      },
      "typeVersion": 1
    },
    {
      "id": "e7865ccb-63a4-42bb-8114-e12e0616036d",
      "name": "Section \u2014 Polling Loop",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 652,
        "height": 100,
        "content": "## 3. Polling Loop\nWaits 45 seconds then checks if clips are ready. Loops back if still processing."
      },
      "typeVersion": 1
    },
    {
      "id": "a0674f67-54bd-4e53-aa89-028483d22394",
      "name": "Section \u2014 Download & Upload",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 660,
        "height": 100,
        "content": "## 4. Extract, Download & Upload\nExtracts each clip metadata, downloads the video file, then uploads to Google Drive."
      },
      "typeVersion": 1
    },
    {
      "id": "c39a061f-0e36-4166-9995-d56bb87ba351",
      "name": "Warning \u2014 Infinite Loop Risk",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        304
      ],
      "parameters": {
        "color": 3,
        "width": 684,
        "height": 124,
        "content": "## \u26a0\ufe0f WARNING \u2014 Infinite Loop Risk\nIf WayinVideo never returns clips (invalid URL or API error), this workflow loops forever. Add a retry counter or max-attempts check in the If node to prevent runaway executions."
      },
      "typeVersion": 1
    },
    {
      "id": "6314a911-15ba-4a52-9d12-8e89a7b84916",
      "name": "Warning \u2014 Hardcoded API Key",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        304
      ],
      "parameters": {
        "color": 3,
        "width": 484,
        "height": 140,
        "content": "## \u26a0\ufe0f WARNING \u2014 Hardcoded API Key\nDo not store the WayinVideo API key in plain text inside node parameters. Move it to an n8n Credential (Header Auth) for security."
      },
      "typeVersion": 1
    },
    {
      "id": "5b82042b-ca35-4854-8d92-d5bedad72ef7",
      "name": "1. Form \u2014 Video URL + Brand + Clip Count",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        352,
        64
      ],
      "parameters": {
        "options": {},
        "formTitle": "\ud83c\udfac Influencer Content Repurposing Pipeline",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Influencer Video URL",
              "placeholder": "https://www.youtube.com/watch?v=xxxxxxx",
              "requiredField": true
            },
            {
              "fieldLabel": "Influencer / Brand Name",
              "placeholder": "e.g. top creators, business influencers, podcast hosts",
              "requiredField": true
            },
            {
              "fieldLabel": "Max Clips to Generate",
              "placeholder": "e.g. 5",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Paste the influencer's long video URL \u2014 AI will extract top viral clips with titles, descriptions, hashtags, and download links."
      },
      "typeVersion": 2.2
    },
    {
      "id": "ff1eb9b6-290f-4d67-a2d7-2f784a4c911d",
      "name": "2. WayinVideo \u2014 Submit Clipping Task",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        624,
        64
      ],
      "parameters": {
        "url": "https://wayinvideo-api.wayin.ai/api/v2/clips",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"video_url\": \"{{ $json['Influencer Video URL'] }}\",\n  \"project_name\": \"{{ $json['Influencer / Brand Name'] }}\",\n  \"target_duration\": \"DURATION_30_60\",\n  \"limit\": {{ $json['Max Clips to Generate'] }},\n  \"enable_export\": true,\n  \"resolution\": \"HD_720\",\n  \"enable_caption\": true,\n  \"enable_ai_reframe\": true,\n  \"ratio\": \"RATIO_9_16\",\n  \"target_lang\": \"en\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "075b8803-7d1a-486c-8868-4156c17479bd",
      "name": "3. Wait \u2014 45 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        864,
        64
      ],
      "parameters": {
        "amount": 45
      },
      "typeVersion": 1.1
    },
    {
      "id": "efab2be7-c425-4cc2-b9d1-b7b0e084bfd3",
      "name": "4. WayinVideo \u2014 Poll Clips Result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1104,
        64
      ],
      "parameters": {
        "url": "=https://wayinvideo-api.wayin.ai/api/v2/clips/results/{{ $('2. WayinVideo \u2014 Submit Clipping Task').item.json.data.id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2f907490-b2a2-47f0-a28c-8811795b1581",
      "name": "5. If \u2014 Clips Ready?",
      "type": "n8n-nodes-base.if",
      "position": [
        1312,
        64
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3226a0aa-8475-4fef-8ae8-810e9f9ae752",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "6b0172bc-0e42-4d44-a0b5-35dd1d02ec82",
      "name": "6. Code \u2014 Extract Clips Array",
      "type": "n8n-nodes-base.code",
      "position": [
        1568,
        48
      ],
      "parameters": {
        "jsCode": "const clips = $json.data.clips;\n\nreturn clips.map(clip => ({\n  json: {\n    title: clip.title,\n    export_link: clip.export_link,\n    score: clip.score,\n    tags: clip.tags,\n    desc: clip.desc,\n    begin_ms: clip.begin_ms,\n    end_ms: clip.end_ms\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "d091e62b-2647-43fc-ab3d-42b1c80296d6",
      "name": "7. HTTP Request \u2014 Download Clip File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1808,
        48
      ],
      "parameters": {
        "url": "={{ $json.export_link }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "f3dda3da-543b-4bf1-8927-242694ad0c0c",
      "name": "8. Google Drive \u2014 Upload Clip",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2048,
        48
      ],
      "parameters": {
        "name": "={{ $('6. Code \u2014 Extract Clips Array').item.json.title }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "cachedResultName": "WayinVideo_Data"
        }
      },
      "typeVersion": 3
    }
  ],
  "connections": {
    "3. Wait \u2014 45 Seconds": {
      "main": [
        [
          {
            "node": "4. WayinVideo \u2014 Poll Clips Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. If \u2014 Clips Ready?": {
      "main": [
        [
          {
            "node": "6. Code \u2014 Extract Clips Array",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "3. Wait \u2014 45 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6. Code \u2014 Extract Clips Array": {
      "main": [
        [
          {
            "node": "7. HTTP Request \u2014 Download Clip File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. WayinVideo \u2014 Poll Clips Result": {
      "main": [
        [
          {
            "node": "5. If \u2014 Clips Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. WayinVideo \u2014 Submit Clipping Task": {
      "main": [
        [
          {
            "node": "3. Wait \u2014 45 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7. HTTP Request \u2014 Download Clip File": {
      "main": [
        [
          {
            "node": "8. Google Drive \u2014 Upload Clip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Form \u2014 Video URL + Brand + Clip Count": {
      "main": [
        [
          {
            "node": "2. WayinVideo \u2014 Submit Clipping Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}