{
  "id": "9ep4J2EilLwr2Qv8",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "DubLab App Video Dubbing and Translate",
  "tags": [],
  "nodes": [
    {
      "id": "9eceba49-99b2-4989-a9e3-001d8a445bd6",
      "name": "Init Dubbing",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -420,
        -80
      ],
      "parameters": {
        "url": "https://api.dublab.app/v1/init-dub",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"dest_lang\": \"{{ $json.language }}\",\n    \"duration\": 30,\n    \"fileType\": \"{{ $json.mimetype }}\",\n    \"name\": \"{{ $json.filename }}\",\n    \"source_lang\": \"auto\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "ApiKey",
              "value": "DUBLAB_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c2426bfe-cffe-4d75-8262-14f5e844768d",
      "name": "Upload Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        60,
        -20
      ],
      "parameters": {
        "url": "={{ $json.upload_url }}",
        "method": "PUT",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "video/mp4"
            }
          ]
        },
        "inputDataFieldName": "=VIDEO_{{ $json.binary_order }}"
      },
      "typeVersion": 4.2
    },
    {
      "id": "ea97d19e-b54e-46f5-bcb3-385af87353b1",
      "name": "Start Dubbing",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        620,
        -160
      ],
      "parameters": {
        "url": "https://api.dublab.app/v1/start-dub",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"id\": \"{{ $json.id }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "ApiKey",
              "value": "DUBLAB_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f5a09337-eb25-4a5b-a00d-cc5c90a9a8d4",
      "name": "Fetch Projects",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        -160
      ],
      "parameters": {
        "url": "https://api.dublab.app/v1/dubs",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "ApiKey",
              "value": "DUBLAB_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e564ebac-5af2-4684-9168-dd0123672543",
      "name": "Combine Videos and Languages",
      "type": "n8n-nodes-base.code",
      "position": [
        -600,
        -260
      ],
      "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;"
      },
      "typeVersion": 2
    },
    {
      "id": "b831d614-d37d-4915-a3bb-f6c9561abd29",
      "name": "Proxy Videos",
      "type": "n8n-nodes-base.merge",
      "position": [
        -200,
        -220
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "780b5045-687d-426a-b683-59b446363760",
      "name": "Proxy Ids",
      "type": "n8n-nodes-base.merge",
      "position": [
        320,
        -160
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "0a651887-ba6d-43db-ba6f-c8ff4cb9802d",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -880,
        460
      ],
      "parameters": {
        "path": "e41c5f62-f2de-4df0-ac29-851837a67282",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "480388e6-34d6-48b2-971c-f7eb78f4f907",
      "name": "Original Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        160
      ],
      "parameters": {
        "url": "={{ $json.body.original_download_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "3028b095-aed6-4b71-8d4d-eb24702fb318",
      "name": "Dubbed Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -580,
        440
      ],
      "parameters": {
        "url": "={{ $json.body.dubbed_download_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "23abad27-ac2e-4f58-a06d-a7318c22889e",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -260,
        100
      ],
      "parameters": {
        "chatId": "123456789",
        "operation": "sendVideo",
        "binaryData": true,
        "additionalFields": {
          "fileName": "Dubbed Video"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "629757fa-9c59-4724-9ede-08b73d62a654",
      "name": "Box",
      "type": "n8n-nodes-base.box",
      "position": [
        -260,
        260
      ],
      "parameters": {
        "fileName": "={{ Math.random().toString(36).slice(2) }}-dubbed-{{ $json.body.dest_lang }}-{{ $json.body.name }}",
        "binaryData": true
      },
      "credentials": {
        "boxOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e0c84a5-5ddc-4628-a391-5771a5f10fa3",
      "name": "Dropbox",
      "type": "n8n-nodes-base.dropbox",
      "position": [
        -260,
        420
      ],
      "parameters": {
        "path": "=/dublab-files/{{ Math.random().toString(36).slice(2) }}-dubbed-{{ $json.body.dest_lang }}-{{ $json.body.name }}",
        "binaryData": true,
        "authentication": "oAuth2"
      },
      "credentials": {
        "dropboxOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0134c66f-d572-4737-90c1-09d835a0478e",
      "name": "YouTube",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -260,
        600
      ],
      "parameters": {
        "title": "={{ $json.body.name }}",
        "options": {},
        "resource": "video",
        "operation": "upload",
        "regionCode": "PL"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e24e81e3-3f1f-4fc6-9d37-d8338b9cb4ca",
      "name": "Postiz",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -260,
        780
      ],
      "parameters": {
        "url": "https://api.postiz.com/api/public/v1/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "POSTIZ_API_KEY"
            },
            {
              "name": "Proxy-Authorization",
              "value": "PROXY_AUTH"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bab5f441-0d29-47d5-bfed-20fd99bf1489",
      "name": "Start",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -860,
        -300
      ],
      "parameters": {
        "options": {},
        "formTitle": "Dub Videos",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Video",
              "requiredField": true,
              "acceptFileTypes": ".mp4"
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Destination Language",
              "multiselect": true,
              "fieldOptions": {
                "values": [
                  {
                    "option": "English"
                  },
                  {
                    "option": "German"
                  },
                  {
                    "option": "Russian"
                  },
                  {
                    "option": "Polish"
                  },
                  {
                    "option": "Spanish"
                  },
                  {
                    "option": "Portuguese"
                  },
                  {
                    "option": "Italian"
                  },
                  {
                    "option": "Arabic"
                  },
                  {
                    "option": "French"
                  },
                  {
                    "option": "Turkish"
                  },
                  {
                    "option": "Dutch"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "52f11162-27df-4f69-992d-880919d5b2c4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1640,
        -280
      ],
      "parameters": {
        "width": 600,
        "height": 360,
        "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)"
      },
      "typeVersion": 1
    },
    {
      "id": "1554519e-f8c1-4735-b513-6e6eaf979c30",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1640,
        460
      ],
      "parameters": {
        "width": 600,
        "height": 180,
        "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.)"
      },
      "typeVersion": 1
    },
    {
      "id": "1bd8ed8e-9d77-4b6e-8478-2aba1e7de564",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        740
      ],
      "parameters": {
        "width": 600,
        "height": 140,
        "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.)"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "00fe9678-8e82-474a-8038-81a38166fa34",
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Combine Videos and Languages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Dubbed Video",
            "type": "main",
            "index": 0
          },
          {
            "node": "Original Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Proxy Ids": {
      "main": [
        [
          {
            "node": "Start Dubbing",
            "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
          }
        ]
      ]
    },
    "Init Dubbing": {
      "main": [
        [
          {
            "node": "Proxy Videos",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Proxy Videos": {
      "main": [
        [
          {
            "node": "Upload Video",
            "type": "main",
            "index": 0
          },
          {
            "node": "Proxy Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video": {
      "main": [
        [
          {
            "node": "Proxy Ids",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Start Dubbing": {
      "main": [
        [
          {
            "node": "Fetch Projects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Projects": {
      "main": [
        []
      ]
    },
    "Original Video": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Videos and Languages": {
      "main": [
        [
          {
            "node": "Init Dubbing",
            "type": "main",
            "index": 0
          },
          {
            "node": "Proxy Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}