{
  "name": "03 - YouTube Publisher",
  "nodes": [
    {
      "parameters": {},
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        250,
        300
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "jsCode": "// Prepare upload data\nconst input = $input.all()[0].json;\n\nreturn {\n  videoPath: input.output,\n  thumbnailPath: input.thumbnail?.output || input.output.replace('.mp4', '_thumb.jpg'),\n  title: input.youtubeTitle,\n  description: input.description,\n  tags: input.tags || [],\n  categoryId: '25', // News & Politics\n  videoId: input.videoId\n};"
      },
      "name": "Prepare Upload",
      "type": "n8n-nodes-base.code",
      "position": [
        450,
        300
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://render-service-production-3b75.up.railway.app/publish-to-youtube",
        "body": {
          "videoPath": "={{ $json.videoPath }}",
          "title": "={{ $json.title }}",
          "description": "={{ $json.description }}",
          "tags": "={{ $json.tags }}",
          "categoryId": "={{ $json.categoryId }}"
        },
        "options": {}
      },
      "name": "YouTube Upload",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        650,
        300
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://render-service-production-3b75.up.railway.app/log-publish",
        "body": {
          "videoId": "={{ $('Prepare Upload').item.json.videoId }}",
          "youtubeVideoId": "={{ $json.data.id }}",
          "title": "={{ $('Prepare Upload').item.json.title }}",
          "publishedAt": "={{ new Date().toISOString() }}",
          "articleUrl": "={{ $('Prepare Upload').item.json.articleUrl }}"
        },
        "options": {}
      },
      "name": "Log to Database",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        850,
        300
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "name": "Success",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1250,
        300
      ],
      "typeVersion": 1
    }
  ],
  "connections": {
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Prepare Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Upload": {
      "main": [
        [
          {
            "node": "YouTube Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube Upload": {
      "main": [
        [
          {
            "node": "Log to Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Database": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": []
}