{
  "name": "Video to SRT (Video Subtitle & Transcript API)",
  "nodes": [
    {
      "parameters": {},
      "id": "a1c0f9d0-0000-4000-8000-000000000001",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1",
              "name": "video_url",
              "value": "https://caption.yosuga.dev/samples/video/sample-30s.mp4",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000002",
      "name": "Set video URL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [220, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://video-subtitle-transcript-api1.p.rapidapi.com/v1/jobs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "X-RapidAPI-Host", "value": "video-subtitle-transcript-api1.p.rapidapi.com" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { source_url: $json.video_url, language: 'ja', mode: 'clean', outputs: ['srt'] } }}",
        "options": {}
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000003",
      "name": "Create job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0],
      "credentials": {
        "httpHeaderAuth": { "id": "REPLACE_WITH_YOUR_CREDENTIAL_ID", "name": "RapidAPI key (X-RapidAPI-Key)" }
      }
    },
    {
      "parameters": { "amount": 20, "unit": "seconds" },
      "id": "a1c0f9d0-0000-4000-8000-000000000004",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [660, 0],
      "webhookId": "a1c0f9d0-0000-4000-8000-00000000wait"
    },
    {
      "parameters": {
        "url": "=https://video-subtitle-transcript-api1.p.rapidapi.com/v1/jobs/{{ $('Create job').item.json.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "X-RapidAPI-Host", "value": "video-subtitle-transcript-api1.p.rapidapi.com" }
          ]
        },
        "options": {}
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000005",
      "name": "Get job",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [880, 0],
      "credentials": {
        "httpHeaderAuth": { "id": "REPLACE_WITH_YOUR_CREDENTIAL_ID", "name": "RapidAPI key (X-RapidAPI-Key)" }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            { "id": "c1", "leftValue": "={{ $json.status }}", "rightValue": "completed", "operator": { "type": "string", "operation": "equals" } }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000006",
      "name": "Completed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1100, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            { "id": "c2", "leftValue": "={{ $json.status }}", "rightValue": "failed", "operator": { "type": "string", "operation": "equals" } }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000007",
      "name": "Failed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1320, 180]
    },
    {
      "parameters": {
        "errorMessage": "={{ $json.error.code }}: {{ $json.error.message }}"
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000008",
      "name": "Stop: job failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [1540, 260]
    },
    {
      "parameters": {
        "url": "={{ $json.files.srt }}",
        "options": { "response": { "response": { "responseFormat": "file", "outputPropertyName": "data" } } }
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000009",
      "name": "Download SRT",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1320, -140]
    },
    {
      "parameters": {
        "name": "={{ $('Create job').item.json.id }}.srt",
        "driveId": { "__rl": true, "mode": "list", "value": "My Drive" },
        "folderId": { "__rl": true, "mode": "list", "value": "root", "cachedResultName": "/ (Root folder)" },
        "options": {}
      },
      "id": "a1c0f9d0-0000-4000-8000-000000000010",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [1540, -140],
      "credentials": {
        "googleDriveOAuth2Api": { "id": "REPLACE_WITH_YOUR_CREDENTIAL_ID", "name": "Google Drive account" }
      }
    }
  ],
  "connections": {
    "Manual Trigger": { "main": [[{ "node": "Set video URL", "type": "main", "index": 0 }]] },
    "Set video URL": { "main": [[{ "node": "Create job", "type": "main", "index": 0 }]] },
    "Create job": { "main": [[{ "node": "Wait", "type": "main", "index": 0 }]] },
    "Wait": { "main": [[{ "node": "Get job", "type": "main", "index": 0 }]] },
    "Get job": { "main": [[{ "node": "Completed?", "type": "main", "index": 0 }]] },
    "Completed?": {
      "main": [
        [{ "node": "Download SRT", "type": "main", "index": 0 }],
        [{ "node": "Failed?", "type": "main", "index": 0 }]
      ]
    },
    "Failed?": {
      "main": [
        [{ "node": "Stop: job failed", "type": "main", "index": 0 }],
        [{ "node": "Wait", "type": "main", "index": 0 }]
      ]
    },
    "Download SRT": { "main": [[{ "node": "Upload to Google Drive", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {},
  "meta": { "templateCredsSetupCompleted": false }
}
