{
  "name": "clipsdk: Drive episodes to YouTube Shorts",
  "nodes": [
    {
      "parameters": {
        "content": "## clipsdk: Drive episodes to YouTube Shorts\n\n1. Create a **Header Auth** credential. Name: `Authorization`. Value: `Bearer csdk_live_...` (your key). Select it on **Get an upload URL** and **Create clips**.\n2. Pick the folder to watch in **New file in Drive**.\n3. Connect YouTube and Airtable, or swap them for any node that takes a file or a row.\n4. n8n must be reachable from the internet: **Wait for clips** resumes when clipsdk calls its URL.\n5. Activate the workflow and drop an episode into the folder.\n\nFiles already at a direct URL? Delete the three upload nodes and put that URL in `video_url`.",
        "height": 340,
        "width": 560,
        "color": 7
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000001",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-40, -420]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 5,
              "unit": "minutes"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000002",
      "name": "New file in Drive",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.clipsdk.com/v1/uploads",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"filename\": {{ JSON.stringify($json.name) }},\n  \"size\": {{ Number($json.size) }}\n}",
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000003",
      "name": "Get an upload URL",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [240, 0]
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $('New file in Drive').item.json.id }}",
          "mode": "id"
        },
        "options": {
          "binaryPropertyName": "data"
        }
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000004",
      "name": "Download the episode",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [480, 0]
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $('Get an upload URL').item.json.upload_url }}",
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {
          "timeout": 3600000
        }
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000005",
      "name": "Upload to clipsdk",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [720, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.clipsdk.com/v1/clips",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "wait",
              "value": "0"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"video_url\": \"{{ $('Get an upload URL').item.json.video_url }}\",\n  \"clips\": 10,\n  \"min_seconds\": 20,\n  \"max_seconds\": 60,\n  \"aspect\": \"9:16\",\n  \"reframe\": \"auto\",\n  \"captions\": \"bold\",\n  \"webhook_url\": \"{{ $execution.resumeUrl }}\"\n}",
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000006",
      "name": "Create clips",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [960, 0]
    },
    {
      "parameters": {
        "resume": "webhook",
        "httpMethod": "POST",
        "limitWaitTime": true,
        "limitType": "afterTimeInterval",
        "resumeAmount": 2,
        "resumeUnit": "hours",
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000007",
      "name": "Wait for clips",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [1200, 0],
      "webhookId": "9f3e7c52-6a1d-4b8e-8c2f-3d4a5b6c7d8e"
    },
    {
      "parameters": {
        "fieldToSplitOut": "body.job.result.clips",
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000008",
      "name": "One item per clip",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [1440, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c2a8f0d4-85a1-4f0b-9a3e-6d1b2c3d4e5f",
              "leftValue": "={{ $json.score }}",
              "rightValue": 85,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000009",
      "name": "Score 85 or higher?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [1680, 0]
    },
    {
      "parameters": {
        "url": "={{ $json.video }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000010",
      "name": "Download the clip",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1920, -100]
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "upload",
        "title": "={{ $('One item per clip').item.json.title }}",
        "regionCode": "US",
        "categoryId": "22",
        "options": {
          "description": "={{ $('One item per clip').item.json.post_caption }}",
          "privacyStatus": "private"
        }
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000011",
      "name": "Upload as a Short",
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [2160, -100]
    },
    {
      "parameters": {
        "operation": "create",
        "base": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "table": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Title": "={{ $json.title }}",
            "Score": "={{ $json.score }}",
            "Reason": "={{ $json.reason }}",
            "Clip": "={{ $json.video }}",
            "Caption": "={{ $json.post_caption }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string"
            },
            {
              "id": "Score",
              "displayName": "Score",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "number"
            },
            {
              "id": "Reason",
              "displayName": "Reason",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string"
            },
            {
              "id": "Clip",
              "displayName": "Clip",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string"
            },
            {
              "id": "Caption",
              "displayName": "Caption",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "5b1c0e7a-1f0e-4c47-9d0a-0c11a0000012",
      "name": "Add to review queue",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [1920, 100]
    }
  ],
  "connections": {
    "New file in Drive": {
      "main": [[{ "node": "Get an upload URL", "type": "main", "index": 0 }]]
    },
    "Get an upload URL": {
      "main": [[{ "node": "Download the episode", "type": "main", "index": 0 }]]
    },
    "Download the episode": {
      "main": [[{ "node": "Upload to clipsdk", "type": "main", "index": 0 }]]
    },
    "Upload to clipsdk": {
      "main": [[{ "node": "Create clips", "type": "main", "index": 0 }]]
    },
    "Create clips": {
      "main": [[{ "node": "Wait for clips", "type": "main", "index": 0 }]]
    },
    "Wait for clips": {
      "main": [[{ "node": "One item per clip", "type": "main", "index": 0 }]]
    },
    "One item per clip": {
      "main": [[{ "node": "Score 85 or higher?", "type": "main", "index": 0 }]]
    },
    "Score 85 or higher?": {
      "main": [
        [{ "node": "Download the clip", "type": "main", "index": 0 }],
        [{ "node": "Add to review queue", "type": "main", "index": 0 }]
      ]
    },
    "Download the clip": {
      "main": [[{ "node": "Upload as a Short", "type": "main", "index": 0 }]]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
