{
  "name": "DarkTube v2 - Orquestrador de Vídeos Dark (Grátis vs Pago)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days"
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Agendamento Diário",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "darktube-trigger",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Externo",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 480]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "param-theme",
              "name": "theme",
              "value": "={{ $json.theme || 'O Ritual Esquecido do Abismo' }}",
              "type": "string"
            },
            {
              "id": "param-mode",
              "name": "mode",
              "value": "={{ $json.mode || 'free' }}",
              "type": "string"
            },
            {
              "id": "param-scenes",
              "name": "num_scenes",
              "value": 5,
              "type": "number"
            }
          ]
        }
      },
      "id": "prepare-data",
      "name": "Preparar Parâmetros",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [480, 380]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.mode }}",
              "value2": "paid"
            }
          ]
        }
      },
      "id": "router-mode",
      "name": "Verificar Categoria (Grátis ou Pago)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [700, 380]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:5055/api/jobs/generate",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "theme",
              "value": "={{ $json.theme }}"
            },
            {
              "name": "mode",
              "value": "free"
            },
            {
              "name": "num_scenes",
              "value": "={{ $json.num_scenes }}"
            },
            {
              "name": "callback_url",
              "value": "http://localhost:5678/webhook/darktube-callback"
            }
          ]
        },
        "options": {}
      },
      "id": "http-free",
      "name": "Disparar Categoria Grátis (Pollinations)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [940, 480]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:5055/api/jobs/generate",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "theme",
              "value": "={{ $json.theme }}"
            },
            {
              "name": "mode",
              "value": "paid"
            },
            {
              "name": "num_scenes",
              "value": "={{ $json.num_scenes }}"
            },
            {
              "name": "callback_url",
              "value": "http://localhost:5678/webhook/darktube-callback"
            }
          ]
        },
        "options": {}
      },
      "id": "http-paid",
      "name": "Disparar Categoria Paga (Gemini/Imagen)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [940, 280]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "darktube-callback",
        "options": {}
      },
      "id": "webhook-callback",
      "name": "Callback de Conclusão",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [1220, 380]
    }
  ],
  "connections": {
    "Agendamento Diário": {
      "main": [
        [
          {
            "node": "Preparar Parâmetros",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Externo": {
      "main": [
        [
          {
            "node": "Preparar Parâmetros",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preparar Parâmetros": {
      "main": [
        [
          {
            "node": "Verificar Categoria (Grátis ou Pago)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verificar Categoria (Grátis ou Pago)": {
      "main": [
        [
          {
            "node": "Disparar Categoria Paga (Gemini/Imagen)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Disparar Categoria Grátis (Pollinations)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {}
}
