{
  "name": "DubLab App Video Dubbing and Translate",
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.dublab.app/v1/init-dub",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "ApiKey",
              "value": "DUBLAB_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"dest_lang\": \"{{ $json.language }}\",\n    \"duration\": 30,\n    \"fileType\": \"{{ $json.mimetype }}\",\n    \"name\": \"{{ $json.filename }}\",\n    \"source_lang\": \"auto\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -420,
        -80
      ],
      "id": "9eceba49-99b2-4989-a9e3-001d8a445bd6",
      "name": "Init Dubbing"
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $json.upload_url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "video/mp4"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "=VIDEO_{{ $json.binary_order }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        60,
        -20
      ],
      "id": "c2426bfe-cffe-4d75-8262-14f5e844768d",
      "name": "Upload Video"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.dublab.app/v1/start-dub",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "ApiKey",
              "value": "DUBLAB_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"id\": \"{{ $json.id }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        620,
        -160
      ],
      "id": "ea97d19e-b54e-46f5-bcb3-385af87353b1",
      "name": "Start Dubbing"
    },
    {
      "parameters": {
        "url": "https://api.dublab.app/v1/dubs",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "ApiKey",
              "value": "DUBLAB_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        -160
      ],
      "id": "f5a09337-eb25-4a5b-a00d-cc5c90a9a8d4",
      "name": "Fetch Projects"
    },
    {
      "parameters": {
        "jsCode": "const langMap = {\n  English: \"en\",\n  German: \"de\",\n  Russian: \"ru\",\n  Polish: \"pl\",\n  Spanish: \"es\",\n  Portuguese: \"pt\",\n  French: \"fr\",\n  Italian: 'it',\n  Turkish: \"tr\",\n  Arabic: \"ar\",\n  Dutch: \"nl\"\n};\n\nconst results = [];\nconsole.log($input)\nlet counter = 1\nlet video_key = 0\n$input.all().forEach(item => {\n  const videos = item.json.Video;\n  const languages = item.json[\"Destination Language\"];\n\n  videos.forEach(video => {\n    languages.forEach(lang => {\n      const video_binary = item.json.Video.length === 1 ? \"Video\" : (\"Video_\"+video_key);\n      results.push({\n        json: {\n          ...video,\n          language: langMap[lang] || lang, // fallback to original if not mapped\n          submittedAt: item.json.submittedAt,\n          formMode: item.json.formMode,\n          binary_order: counter\n        },\n        binary: { \n          [\"VIDEO_\" + counter] : item.binary[video_binary]\n        }\n      });\n      counter +=1\n    });\n    video_key +=1\n  });\n});\n\nreturn results;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -600,
        -260
      ],
      "id": "e564ebac-5af2-4684-9168-dd0123672543",
      "name": "Combine Videos and Languages"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        -200,
        -220
      ],
      "id": "b831d614-d37d-4915-a3bb-f6c9561abd29",
      "name": "Proxy Videos"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        320,
        -160
      ],
      "id": "780b5045-687d-426a-b683-59b446363760",
      "name": "Proxy Ids"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "e41c5f62-f2de-4df0-ac29-851837a67282",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -880,
        460
      ],
      "id": "0a651887-ba6d-43db-ba6f-c8ff4cb9802d",
      "name": "Webhook",
      "webhookId": "e41c5f62-f2de-4df0-ac29-851837a67282"
    },
    {
      "parameters": {
        "url": "={{ $json.body.original_download_url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -580,
        160
      ],
      "id": "480388e6-34d6-48b2-971c-f7eb78f4f907",
      "name": "Original Video"
    },
    {
      "parameters": {
        "url": "={{ $json.body.dubbed_download_url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -580,
        440
      ],
      "id": "3028b095-aed6-4b71-8d4d-eb24702fb318",
      "name": "Dubbed Video"
    },
    {
      "parameters": {
        "operation": "sendVideo",
        "chatId": "145187085",
        "binaryData": true,
        "additionalFields": {
          "fileName": "Dubbed Video"
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -260,
        100
      ],
      "id": "23abad27-ac2e-4f58-a06d-a7318c22889e",
      "name": "Telegram",
      "webhookId": "20a81b1b-f38d-4e08-b301-a9e6ac2b951a",
      "credentials": {
        "telegramApi": {
          "id": "oFYckTt5TXjqEbLX",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "fileName": "={{ Math.random().toString(36).slice(2) }}-dubbed-{{ $json.body.dest_lang }}-{{ $json.body.name }}",
        "binaryData": true
      },
      "type": "n8n-nodes-base.box",
      "typeVersion": 1,
      "position": [
        -260,
        260
      ],
      "id": "629757fa-9c59-4724-9ede-08b73d62a654",
      "name": "Box",
      "credentials": {
        "boxOAuth2Api": {
          "id": "2AurohQtPXu9w5Ev",
          "name": "Box account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "path": "=/dublab-files/{{ Math.random().toString(36).slice(2) }}-dubbed-{{ $json.body.dest_lang }}-{{ $json.body.name }}",
        "binaryData": true
      },
      "type": "n8n-nodes-base.dropbox",
      "typeVersion": 1,
      "position": [
        -260,
        420
      ],
      "id": "9e0c84a5-5ddc-4628-a391-5771a5f10fa3",
      "name": "Dropbox",
      "credentials": {
        "dropboxOAuth2Api": {
          "id": "KaBWvQNCjKDgcxYH",
          "name": "Dropbox account"
        }
      }
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "upload",
        "title": "={{ $json.body.name }}",
        "regionCode": "PL",
        "options": {}
      },
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [
        -260,
        600
      ],
      "id": "0134c66f-d572-4737-90c1-09d835a0478e",
      "name": "YouTube",
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "lDxH7eygurgvuWpp",
          "name": "YouTube account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.postiz.com/api/public/v1/upload",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "POSTIZ_API_KEY"
            },
            {
              "name": "Proxy-Authorization",
              "value": "PROXY_AUTH"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -260,
        780
      ],
      "id": "e24e81e3-3f1f-4fc6-9d37-d8338b9cb4ca",
      "name": "Postiz"
    },
    {
      "parameters": {
        "formTitle": "Dub Videos",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Video",
              "fieldType": "file",
              "acceptFileTypes": ".mp4",
              "requiredField": true
            },
            {
              "fieldLabel": "Destination Language",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "English"
                  },
                  {
                    "option": "German"
                  },
                  {
                    "option": "Russian"
                  },
                  {
                    "option": "Polish"
                  },
                  {
                    "option": "Spanish"
                  },
                  {
                    "option": "Portuguese"
                  },
                  {
                    "option": "Italian"
                  },
                  {
                    "option": "Arabic"
                  },
                  {
                    "option": "French"
                  },
                  {
                    "option": "Turkish"
                  },
                  {
                    "option": "Dutch"
                  }
                ]
              },
              "multiselect": true,
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        -860,
        -300
      ],
      "id": "bab5f441-0d29-47d5-bfed-20fd99bf1489",
      "name": "Start",
      "webhookId": "85d519f9-3df6-4377-833c-4355a34ebbab"
    },
    {
      "parameters": {
        "content": "## Dub Videos And Share on Social Media\n\n### Workflows\n----------\n 1. Via n8n form select files to dub for desired languages.\n 2. Listen webhook and whenever dubbing finishes upload to desired platforms\n\n### Used Stacks\n-------------\n - DubLab App (ApiKey, Webhook Setup Required)\n - Telegram (Token Required)\n - Box (Oauth2 Required)\n - Dropbox (Oauth2 Required)\n - Youtube (Oauth2 Required)\n - Postiz (ApiKey Required)",
        "height": 360,
        "width": 600
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1640,
        -280
      ],
      "id": "52f11162-27df-4f69-992d-880919d5b2c4",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## How to Use\n\n - Obtain Api Key from https://dublab.app, set as variable or just update on nodes.\n - Grab Webhook Url and add to DubLab App\n - Setup upload providers (Telegram, Box, Dropbox, YouTube, Postiz etc.)",
        "height": 180,
        "width": 600
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1640,
        460
      ],
      "id": "1554519e-f8c1-4735-b513-6e6eaf979c30",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "### Postiz\n - https://postiz.com/\n - Pretty neat tool which supports many social media platforms\n - Supports cloud and self-hosted version\n - Via API post can be shared over below platforms (Facebook, Instagram, Threads, Tiktok, Reddit etc.)",
        "height": 140,
        "width": 600
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        740
      ],
      "id": "1bd8ed8e-9d77-4b6e-8478-2aba1e7de564",
      "name": "Sticky Note2"
    }
  ],
  "pinData": {},
  "connections": {
    "Init Dubbing": {
      "main": [
        [
          {
            "node": "Proxy Videos",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Upload Video": {
      "main": [
        [
          {
            "node": "Proxy Ids",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Start Dubbing": {
      "main": [
        [
          {
            "node": "Fetch Projects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Projects": {
      "main": [
        []
      ]
    },
    "Combine Videos and Languages": {
      "main": [
        [
          {
            "node": "Init Dubbing",
            "type": "main",
            "index": 0
          },
          {
            "node": "Proxy Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Proxy Videos": {
      "main": [
        [
          {
            "node": "Upload Video",
            "type": "main",
            "index": 0
          },
          {
            "node": "Proxy Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Proxy Ids": {
      "main": [
        [
          {
            "node": "Start Dubbing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Dubbed Video",
            "type": "main",
            "index": 0
          },
          {
            "node": "Original Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dubbed Video": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Box",
            "type": "main",
            "index": 0
          },
          {
            "node": "Dropbox",
            "type": "main",
            "index": 0
          },
          {
            "node": "YouTube",
            "type": "main",
            "index": 0
          },
          {
            "node": "Postiz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Original Video": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Combine Videos and Languages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "00fe9678-8e82-474a-8038-81a38166fa34",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "cdead8ad85d97beb6ccc10a2ca33665d26529396bcde1290665cf5cc5a67f620"
  },
  "id": "9ep4J2EilLwr2Qv8",
  "tags": []
}