{
  "id": "wf007-media-production-00000000",
  "name": "WF-007-media-production",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 * * * *"
            }
          ]
        }
      },
      "id": "c70700000-0007-0007-0007-000000000001",
      "name": "Schedule 1hr",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        500
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT s.* FROM scripts s LEFT JOIN media_assets ma ON ma.script_id = s.id AND ma.media_type = 'video' WHERE s.status = 'approved' AND ma.id IS NULL LIMIT 1",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000002",
      "name": "Poll Scripts Needing Media",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        220,
        500
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "any",
                "operation": "exists"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000003",
      "name": "Has Script?",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        440,
        500
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=SELECT ca.id AS asset_id, ca.channel_id, ca.visual_concepts, ca.thumbnail_concepts, s.id AS script_id, s.platform, s.script_text, s.title FROM content_assets ca JOIN scripts s ON s.asset_id = ca.id WHERE s.id = {{ $json.id }}",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000004",
      "name": "Fetch Asset For Script",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        660,
        500
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://media-api:8080/api/v1/tts",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ script_text: $json.script_text, voice: $env.TTS_VOICE || 'bm_fable', platform: $json.platform, asset_id: $json.asset_id, script_id: $json.script_id, channel_id: $json.channel_id }) }}",
        "options": {
          "timeout": 120000
        }
      },
      "id": "c70700000-0007-0007-0007-000000000005",
      "name": "Generate Audio",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        260
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.success }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000006",
      "name": "Audio Success?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1100,
        260
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO media_assets (asset_id, script_id, channel_id, media_type, file_path, file_size_bytes, duration_s, status) VALUES ({{ $('Fetch Asset For Script').first().json.asset_id }}, {{ $('Fetch Asset For Script').first().json.script_id }}, {{ $('Fetch Asset For Script').first().json.channel_id }}, 'audio', '{{ $json.file_path }}', {{ $json.file_size_bytes }}, {{ $json.duration_s }}, 'ready') RETURNING id",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000007",
      "name": "Insert Audio Media",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1320,
        260
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return [{ json: {\n  workflow_name: 'WF-007-media-production',\n  execution_id: String($execution.id),\n  node_name: 'Generate Audio',\n  error_type: 'media_generation_failed',\n  error_message: `TTS generation failed: ${$json.error || 'unknown error'}`,\n  payload: { asset_id: $('Fetch Asset For Script').first().json.asset_id, script_id: $('Fetch Asset For Script').first().json.script_id }\n} }];"
      },
      "id": "c70700000-0007-0007-0007-000000000008",
      "name": "Build DLQ Payload Audio",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        420
      ]
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "sub002-dead-letter-queue-0000000",
          "mode": "id"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000009",
      "name": "Log to SUB-002 Audio",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.1,
      "position": [
        1540,
        420
      ]
    },
    {
      "parameters": {
        "jsCode": "const ctx = $('Fetch Asset For Script').first().json;\nconst concepts = ctx.visual_concepts || [];\nreturn concepts.map((vc, idx) => ({ json: {\n  description: vc.description || vc.scene || '',\n  style: vc.style || '',\n  mood: vc.mood || '',\n  scene_index: idx + 1,\n  asset_id: ctx.asset_id,\n  channel_id: ctx.channel_id,\n  platform: ctx.platform\n} }));"
      },
      "id": "c70700000-0007-0007-0007-000000000010",
      "name": "Fan Out Visual Concepts",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        500
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://media-api:8080/api/v1/image",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ image_prompt: [$json.description, $json.style, $json.mood, 'cinematic, dark corporate aesthetic, dramatic side lighting, 4K photorealistic, news documentary style, high contrast, shallow depth of field, no text, no logos'].filter(Boolean).join(', '), negative_prompt: 'cartoon, illustration, bright colors, generic stock photo, cheerful, clipart, watermark, text overlay, logo', aspect_ratio: $json.platform === 'youtube_short' ? '9:16' : '16:9', asset_id: $json.asset_id, scene_index: $json.scene_index, channel_id: $json.channel_id }) }}",
        "options": {
          "timeout": 60000
        }
      },
      "id": "c70700000-0007-0007-0007-000000000011",
      "name": "Generate Image",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        500
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.success }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000012",
      "name": "Image Success?",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        1320,
        500
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO media_assets (asset_id, channel_id, media_type, file_path, file_size_bytes, resolution, status) VALUES ({{ $('Fan Out Visual Concepts').item.json.asset_id }}, {{ $('Fan Out Visual Concepts').item.json.channel_id }}, 'image', '{{ $json.file_path }}', {{ $json.file_size_bytes || 'NULL' }}, '{{ $json.resolution || '' }}', 'ready') RETURNING file_path",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000013",
      "name": "Insert Image Media",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1540,
        500
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "images"
      },
      "id": "c70700000-0007-0007-0007-000000000014",
      "name": "Aggregate Image Paths",
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        1760,
        500
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://media-api:8080/api/v1/thumbnail",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ headline: ($json.thumbnail_concepts || [])[0]?.headline || '', visual: ($json.thumbnail_concepts || [])[0]?.visual || '', emotion: ($json.thumbnail_concepts || [])[0]?.emotion || 'neutral', asset_id: $json.asset_id, channel_id: $json.channel_id }) }}",
        "options": {
          "timeout": 60000
        }
      },
      "id": "c70700000-0007-0007-0007-000000000015",
      "name": "Generate Thumbnail",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        720
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO media_assets (asset_id, channel_id, media_type, file_path, file_size_bytes, resolution, status) VALUES ({{ $('Fetch Asset For Script').first().json.asset_id }}, {{ $('Fetch Asset For Script').first().json.channel_id }}, 'thumbnail', '{{ $json.file_path || '' }}', {{ $json.file_size_bytes || 'NULL' }}, '{{ $json.resolution || '' }}', '{{ $json.success ? 'ready' : 'failed' }}') RETURNING id",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000016",
      "name": "Insert Thumbnail Media",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1100,
        720
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "numberInputs": 3
      },
      "id": "c70700000-0007-0007-0007-000000000017",
      "name": "Join Media Branches",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1980,
        480
      ]
    },
    {
      "parameters": {
        "jsCode": "const ctx = $('Fetch Asset For Script').first().json;\nconst audio = $('Generate Audio').first().json;\nlet images = [];\ntry { images = ($('Aggregate Image Paths').first().json.images || []).map(i => i.file_path).filter(Boolean); } catch (e) { images = []; }\nconst isShort = ctx.platform === 'youtube_short';\nreturn [{ json: {\n  script_id: ctx.script_id,\n  asset_id: ctx.asset_id,\n  channel_id: ctx.channel_id,\n  platform: ctx.platform,\n  title: ctx.title,\n  audio_file_path: audio.file_path,\n  image_file_paths: images,\n  output_resolution: isShort ? '1080x1920' : '1920x1080',\n  needs_subtitles: isShort\n} }];"
      },
      "id": "c70700000-0007-0007-0007-000000000018",
      "name": "Build Assemble Payload",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2200,
        480
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.audio_file_path }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000032",
      "name": "Has Audio?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2420,
        480
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.needs_subtitles }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000019",
      "name": "Is Short?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2640,
        480
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://media-api:8080/api/v1/subtitles",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ audio_file_path: $json.audio_file_path, asset_id: $json.asset_id, script_id: $json.script_id, channel_id: $json.channel_id }) }}",
        "options": {
          "timeout": 180000
        }
      },
      "id": "c70700000-0007-0007-0007-000000000020",
      "name": "Generate Subtitles",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2640,
        380
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO media_assets (asset_id, script_id, channel_id, media_type, file_path, status) VALUES ({{ $('Build Assemble Payload').first().json.asset_id }}, {{ $('Build Assemble Payload').first().json.script_id }}, {{ $('Build Assemble Payload').first().json.channel_id }}, 'subtitle', '{{ $json.srt_file_path || '' }}', '{{ $json.success ? 'ready' : 'failed' }}') RETURNING id",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000021",
      "name": "Insert Subtitle Media",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        2860,
        380
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "let subtitlePath = null;\ntry { subtitlePath = $('Generate Subtitles').first().json.srt_file_path || null; } catch (e) { subtitlePath = null; }\nreturn [{ json: { ...$('Build Assemble Payload').first().json, subtitle_file_path: subtitlePath } }];"
      },
      "id": "c70700000-0007-0007-0007-000000000022",
      "name": "Resolve Subtitle Path",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3080,
        480
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://media-api:8080/api/v1/assemble",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ script_id: $json.script_id, asset_id: $json.asset_id, channel_id: $json.channel_id, platform: $json.platform, audio_file_path: $json.audio_file_path, image_file_paths: $json.image_file_paths, subtitle_file_path: $json.subtitle_file_path, output_resolution: $json.output_resolution }) }}",
        "options": {
          "timeout": 1200000
        }
      },
      "id": "c70700000-0007-0007-0007-000000000023",
      "name": "Assemble Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3300,
        480
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.success }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000024",
      "name": "Assembly Success?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        3520,
        480
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO media_assets (asset_id, script_id, channel_id, media_type, file_path, file_size_bytes, duration_s, resolution, status) VALUES ({{ $('Resolve Subtitle Path').first().json.asset_id }}, {{ $('Resolve Subtitle Path').first().json.script_id }}, {{ $('Resolve Subtitle Path').first().json.channel_id }}, 'video', '{{ $json.video_file_path }}', {{ $json.file_size_bytes }}, {{ $json.duration_s }}, '{{ $json.resolution || '' }}', 'ready') RETURNING id",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000025",
      "name": "Insert Video Media",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3740,
        380
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO publishing_records (asset_id, script_id, channel_id, platform, status) VALUES ({{ $('Resolve Subtitle Path').first().json.asset_id }}, {{ $('Resolve Subtitle Path').first().json.script_id }}, {{ $('Resolve Subtitle Path').first().json.channel_id }}, '{{ $('Resolve Subtitle Path').first().json.platform }}', 'pending_approval') RETURNING id",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000026",
      "name": "Insert Publishing Record",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3960,
        380
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const esc = s => String(s == null ? '' : s).replace(/_/g, ' ').replace(/[*`\\[]/g, '');\nconst ctx = $('Resolve Subtitle Path').first().json;\nconst video = $('Assemble Video').first().json;\nconst pr = $('Insert Publishing Record').first().json;\nconst sizeMb = video.file_size_bytes ? (video.file_size_bytes / (1024*1024)).toFixed(1) : '0';\nreturn [{ json: {\n  message: `\\ud83c\\udfac *VIDEO READY FOR APPROVAL*\\n\\nTitle: ${esc(ctx.title)}\\nPlatform: ${esc(ctx.platform)}\\nDuration: ${Math.round(video.duration_s || 0)}s\\nFile size: ${sizeMb}MB`,\n  parse_mode: 'Markdown',\n  inline_keyboard: [[ { text: '\\u2705 Approve & Publish', callback_data: `approve_video_${pr.id}` }, { text: '\\u274c Reject', callback_data: `reject_video_${pr.id}` } ]]\n} }];"
      },
      "id": "c70700000-0007-0007-0007-000000000027",
      "name": "Build Approval Message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        4180,
        380
      ]
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "sub003-telegram-notification-000000",
          "mode": "id"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000028",
      "name": "Notify Video Approval",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.1,
      "position": [
        4400,
        380
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO workflow_logs (workflow_name, execution_id, status, input_summary, output_summary) VALUES ('WF-007-media-production', '{{ $execution.id }}', 'completed', '{{ JSON.stringify({ script_id: $('Resolve Subtitle Path').first().json.script_id, asset_id: $('Resolve Subtitle Path').first().json.asset_id }) }}'::jsonb, '{{ JSON.stringify({ video_file_path: $('Assemble Video').first().json.video_file_path }) }}'::jsonb)",
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000029",
      "name": "Log Result Success",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        4620,
        380
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return [{ json: {\n  workflow_name: 'WF-007-media-production',\n  execution_id: String($execution.id),\n  node_name: 'Assemble Video',\n  error_type: 'media_generation_failed',\n  error_message: `Video assembly failed: ${$json.error || 'unknown error'}`,\n  payload: { asset_id: $('Resolve Subtitle Path').first().json.asset_id, script_id: $('Resolve Subtitle Path').first().json.script_id }\n} }];"
      },
      "id": "c70700000-0007-0007-0007-000000000030",
      "name": "Build DLQ Payload Assembly",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3740,
        600
      ]
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "sub002-dead-letter-queue-0000000",
          "mode": "id"
        },
        "options": {}
      },
      "id": "c70700000-0007-0007-0007-000000000031",
      "name": "Log to SUB-002 Assembly",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.1,
      "position": [
        3960,
        600
      ]
    }
  ],
  "connections": {
    "Schedule 1hr": {
      "main": [
        [
          {
            "node": "Poll Scripts Needing Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll Scripts Needing Media": {
      "main": [
        [
          {
            "node": "Has Script?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Script?": {
      "main": [
        [
          {
            "node": "Fetch Asset For Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Asset For Script": {
      "main": [
        [
          {
            "node": "Generate Audio",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fan Out Visual Concepts",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate Thumbnail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Audio": {
      "main": [
        [
          {
            "node": "Audio Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audio Success?": {
      "main": [
        [
          {
            "node": "Insert Audio Media",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build DLQ Payload Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build DLQ Payload Audio": {
      "main": [
        [
          {
            "node": "Log to SUB-002 Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Audio Media": {
      "main": [
        [
          {
            "node": "Join Media Branches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fan Out Visual Concepts": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image": {
      "main": [
        [
          {
            "node": "Image Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image Success?": {
      "main": [
        [
          {
            "node": "Insert Image Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Image Media": {
      "main": [
        [
          {
            "node": "Aggregate Image Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Image Paths": {
      "main": [
        [
          {
            "node": "Join Media Branches",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Generate Thumbnail": {
      "main": [
        [
          {
            "node": "Insert Thumbnail Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Thumbnail Media": {
      "main": [
        [
          {
            "node": "Join Media Branches",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Join Media Branches": {
      "main": [
        [
          {
            "node": "Build Assemble Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Assemble Payload": {
      "main": [
        [
          {
            "node": "Has Audio?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Audio?": {
      "main": [
        [
          {
            "node": "Is Short?",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Is Short?": {
      "main": [
        [
          {
            "node": "Generate Subtitles",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Resolve Subtitle Path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Subtitles": {
      "main": [
        [
          {
            "node": "Insert Subtitle Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Subtitle Media": {
      "main": [
        [
          {
            "node": "Resolve Subtitle Path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resolve Subtitle Path": {
      "main": [
        [
          {
            "node": "Assemble Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assemble Video": {
      "main": [
        [
          {
            "node": "Assembly Success?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Assembly Success?": {
      "main": [
        [
          {
            "node": "Insert Video Media",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build DLQ Payload Assembly",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build DLQ Payload Assembly": {
      "main": [
        [
          {
            "node": "Log to SUB-002 Assembly",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Video Media": {
      "main": [
        [
          {
            "node": "Insert Publishing Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Publishing Record": {
      "main": [
        [
          {
            "node": "Build Approval Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Approval Message": {
      "main": [
        [
          {
            "node": "Notify Video Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Video Approval": {
      "main": [
        [
          {
            "node": "Log Result Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}