{
  "name": "Vorlux AI | YouTube Upload Pipeline",
  "active": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "youtube-upload",
        "options": { "responseMode": "lastNode" }
      },
      "id": "webhook-trigger",
      "name": "Upload Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [220, 300]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const data = $input.first().json.body || $input.first().json;\nreturn [{ json: {\n  videoPath: data.videoPath || data.filePath,\n  title: data.title || 'Untitled Video',\n  description: data.description || '',\n  tags: data.tags || [],\n  category: data.category || 'Science & Technology',\n  privacy: data.privacy || 'private',\n  playlist: data.playlist || null,\n  scheduledAt: data.scheduledAt || null,\n  thumbnailPath: data.thumbnailPath || null\n} }];"
      },
      "id": "prepare-metadata",
      "name": "Prepare Metadata",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/studio/content/thumbnail",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: $json.title, style: 'youtube-thumbnail' }) }}",
        "options": { "timeout": 120000 }
      },
      "id": "generate-thumbnail",
      "name": "Generate Thumbnail",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [700, 200]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/ai/completion",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ prompt: 'Optimize this YouTube video description for SEO. Add relevant hashtags and timestamps placeholder. Title: ' + $json.title + '. Original description: ' + $json.description, model: 'gpt-4o-mini' }) }}",
        "options": { "timeout": 30000 }
      },
      "id": "optimize-description",
      "name": "SEO Optimize Description",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [700, 400]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/integrations/youtube",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ action: 'upload', videoPath: $('Prepare Metadata').first().json.videoPath, title: $('Prepare Metadata').first().json.title, description: $('SEO Optimize Description').first().json.text || $('Prepare Metadata').first().json.description, tags: $('Prepare Metadata').first().json.tags, category: $('Prepare Metadata').first().json.category, privacy: $('Prepare Metadata').first().json.privacy, thumbnailUrl: $('Generate Thumbnail').first().json.url }) }}",
        "options": { "timeout": 300000 }
      },
      "id": "upload-youtube",
      "name": "Upload to YouTube",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [980, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: '📹 **YouTube Upload Complete**\\nTitle: ' + $('Prepare Metadata').first().json.title + '\\nPrivacy: ' + $('Prepare Metadata').first().json.privacy }) }}"
      },
      "id": "discord-notify",
      "name": "Discord Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1220, 300]
    }
  ],
  "connections": {
    "Upload Webhook": { "main": [[{ "node": "Prepare Metadata", "type": "main", "index": 0 }]] },
    "Prepare Metadata": { "main": [[{ "node": "Generate Thumbnail", "type": "main", "index": 0 }, { "node": "SEO Optimize Description", "type": "main", "index": 0 }]] },
    "Generate Thumbnail": { "main": [[{ "node": "Upload to YouTube", "type": "main", "index": 0 }]] },
    "SEO Optimize Description": { "main": [[{ "node": "Upload to YouTube", "type": "main", "index": 0 }]] },
    "Upload to YouTube": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
