{
  "name": "Vorlux AI | VOD Quality Assurance",
  "nodes": [
    {
      "id": "1f557a41-e2e1-4e42-89df-9e2cb6d2b8e1",
      "name": "VOD Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ],
      "webhookId": "3c7cfd2a-0c83-48dc-a28c-453fb650c058",
      "parameters": {
        "httpMethod": "POST",
        "path": "vod-qa",
        "options": {
          "responseMode": "lastNode"
        }
      }
    },
    {
      "id": "411bd717-6630-4efe-8279-c4621bdbeb56",
      "name": "Parse VOD",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const d = $input.first().json.body || $input.first().json;\nreturn [{ json: { vodUrl: d.vodUrl || '', title: d.title || '', sessionId: d.sessionId || '', duration: d.durationMinutes || 0 } }];"
      }
    },
    {
      "id": "1dab6f75-d791-4c18-b457-94b0010a4e80",
      "name": "Check VOD URL",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        200
      ],
      "parameters": {
        "method": "HEAD",
        "url": "={{ $json.vodUrl }}",
        "options": {
          "timeout": 10000
        }
      },
      "notes": "Verifies VOD URL is accessible via HEAD request"
    },
    {
      "id": "68623665-3f64-4d47-8f82-014d64744a47",
      "name": "Get Session",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        400
      ],
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/broadcast/sessions/{{ $json.sessionId }}",
        "options": {
          "timeout": 15000
        }
      },
      "notes": "Fetches full session data from Hub"
    },
    {
      "id": "11fd36dd-a3ec-4701-9d59-4971924dfb4d",
      "name": "QA Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ],
      "notes": "Scores VOD: accessibility, duration, transcript, metadata. 0-100 scale.",
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const vodOk = !$node['Check VOD URL'].json.error;\nconst session = $node['Get Session'].json.data || {};\nconst dur = $node['Parse VOD'].json.duration;\nconst issues = [];\nif (!vodOk) issues.push('VOD URL not accessible');\nif (dur < 5) issues.push('VOD under 5 minutes');\nif (!session.transcript && dur > 30) issues.push('No transcript');\nconst score = Math.max(0, 100 - issues.length * 25);\nreturn [{ json: { score, status: score >= 75 ? 'passed' : 'failed', issues } }];"
      }
    },
    {
      "id": "f1b6c836-e5cc-4d5c-b4a6-f0f3cd0d430b",
      "name": "Save QA",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1140,
        200
      ],
      "parameters": {
        "method": "PUT",
        "url": "={{$env.VORLUX_HUB_URL}}/api/broadcast/sessions/{{ $node['Parse VOD'].json.sessionId }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"qa_status\":\"{{ $json.status }}\",\"qa_score\":{{ $json.score }}}",
        "options": {
          "timeout": 15000
        }
      }
    },
    {
      "id": "6bf98ce5-b586-415c-b418-55d3f8153dfe",
      "name": "Alert Issues",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1140,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_OPS_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"VOD QA: {{ $json.status }}\",\"description\":\"Score: {{ $json.score }}/100\\nIssues: {{ $json.issues.join(\\\", \\\") }}\",\"color\":{{ $json.score >= 75 ? 5763719 : 15158332 }}}]}",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "3c1324e5-0105-472b-8841-3e663efe6bcc",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1380,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({score:$json.score,status:$json.status}) }}"
      }
    }
  ],
  "connections": {
    "VOD Webhook": {
      "main": [
        [
          {
            "node": "Parse VOD",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse VOD": {
      "main": [
        [
          {
            "node": "Check VOD URL",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check VOD URL": {
      "main": [
        [
          {
            "node": "QA Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Session": {
      "main": [
        [
          {
            "node": "QA Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QA Score": {
      "main": [
        [
          {
            "node": "Save QA",
            "type": "main",
            "index": 0
          },
          {
            "node": "Alert Issues",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save QA": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert Issues": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}