{
  "name": "A \u2014 \u041f\u0440\u0438\u0451\u043c \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 (\u0427\u0435\u043b\u043b\u0435\u043d\u0434\u0436 200 \u0434\u043d\u0435\u0439)",
  "nodes": [
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "id": "a-trigger",
      "name": "\u0417\u0430\u043f\u0443\u0441\u043a \u0438\u0437 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -1400,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const msg = $json.message || {};\nconst video = msg.video || ((msg.document && (msg.document.mime_type || '').startsWith('video/')) ? msg.document : null);\nconst text = msg.text || '';\nconst driveMatch = text.match(/https:\\/\\/drive\\.google\\.com\\/\\S+/);\n\nlet route = 'invalid';\nlet fileId = null;\nlet fileSize = 0;\nlet driveUrl = null;\n\nif (video) {\n  fileId = video.file_id;\n  fileSize = video.file_size || 0;\n  // Bot API \u043e\u0442\u0434\u0430\u0451\u0442 \u043d\u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c ~20 \u041c\u0411\n  route = fileSize > 1900 * 1024 * 1024 ? 'too_big' : 'video';\n} else if (driveMatch) {\n  route = 'drive_link';\n  driveUrl = driveMatch[0];\n}\n\nreturn [{ json: { route, fileId, fileSize, driveUrl, chatId: msg.chat.id } }];"
      },
      "id": "a-classify",
      "name": "\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u0430",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1180,
        0
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "video",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "video"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "drive_link",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "drive_link"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "too_big",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "too_big"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "invalid",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "invalid"
            }
          ]
        },
        "options": {}
      },
      "id": "a-switch",
      "name": "\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        -960,
        0
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "\u041f\u0440\u0438\u0448\u043b\u0438 \u0432\u0438\u0434\u0435\u043e\u0444\u0430\u0439\u043b (\u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 Google Drive \u0441 \u0432\u0438\u0434\u0435\u043e).",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "a-hint-invalid",
      "name": "\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u043f\u0440\u0438\u0448\u043b\u0438 \u0432\u0438\u0434\u0435\u043e",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -720,
        320
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "\u0424\u0430\u0439\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 (>2 \u0413\u0411). \u041f\u0440\u0438\u0448\u043b\u0438 \u0440\u043e\u043b\u0438\u043a \u043f\u043e\u043a\u043e\u0440\u043e\u0447\u0435 \u0438\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 Google Drive.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "a-hint-big",
      "name": "\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0430\u0439\u043b",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -720,
        200
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "url": "=http://127.0.0.1:8081/bot{{ $env.TELEGRAM_BOT_TOKEN }}/getFile?file_id={{ $json.fileId }}",
        "options": {}
      },
      "id": "a-getfile",
      "name": "TG getFile (local)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -720,
        -120
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "jsCode": "const p = ($json.result && $json.result.file_path) || '';\nif (!p) throw new Error('getFile \u043d\u0435 \u0432\u0435\u0440\u043d\u0443\u043b file_path. \u041e\u0442\u0432\u0435\u0442: ' + JSON.stringify($json).slice(0,300));\nconst host = p.replace('/var/lib/telegram-bot-api', '/var/snap/docker/common/var-lib-docker/volumes/tba-data/_data');\nconst ext = (p.split('.').pop() || 'mp4').replace(/[^a-zA-Z0-9]/g,'').slice(0,5) || 'mp4';\nconst dest = '/root/.n8n-files/tg_' + Date.now() + '.' + ext;\nreturn [{ json: { file_path: p, host_path: host, dest } }];"
      },
      "id": "a-hostpath",
      "name": "\u041f\u0443\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442\u0435",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -540,
        -120
      ]
    },
    {
      "parameters": {
        "command": "=mkdir -p /root/.n8n-files && cp \"{{ $json.host_path }}\" \"{{ $json.dest }}\""
      },
      "id": "a-copyfile",
      "name": "\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        -450,
        -120
      ],
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 3000
    },
    {
      "parameters": {
        "operation": "read",
        "fileSelector": "={{ $('\u041f\u0443\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442\u0435').first().json.dest }}",
        "options": {}
      },
      "id": "a-readfile",
      "name": "\u0427\u0438\u0442\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0441 \u0434\u0438\u0441\u043a\u0430",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        -270,
        -120
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "name": "=raw_{{ $now.format('yyyy-MM-dd_HH-mm') }}.mp4",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GDRIVE_FOLDER_RAW }}"
        },
        "options": {}
      },
      "id": "a-drive-raw",
      "name": "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (raw)",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -500,
        -120
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 10000
    },
    {
      "parameters": {
        "operation": "share",
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        },
        "options": {}
      },
      "id": "a-share-raw",
      "name": "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f (raw)",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -280,
        -120
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "raw-url",
              "name": "raw_url",
              "type": "string",
              "value": "=https://drive.usercontent.google.com/download?export=download&confirm=t&id={{ $('\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (raw)').first().json.id }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a-set-rawurl",
      "name": "raw_url \u0438\u0437 Drive",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -60,
        -120
      ]
    },
    {
      "parameters": {
        "jsCode": "const url = $json.driveUrl || '';\nconst m = url.match(/\\/d\\/([\\w-]+)/) || url.match(/[?&]id=([\\w-]+)/);\nconst raw_url = m ? `https://drive.usercontent.google.com/download?export=download&confirm=t&id=${m[1]}` : url;\nreturn [{ json: { raw_url } }];"
      },
      "id": "a-normalize-link",
      "name": "\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 Drive",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -60,
        60
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GOOGLE_SHEETS_ID }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "pipeline"
        },
        "options": {}
      },
      "id": "a-sheets-read",
      "name": "\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        160,
        0
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "jsCode": "let rawUrl = null;\ntry { rawUrl = $('raw_url \u0438\u0437 Drive').first().json.raw_url; } catch (e) {}\nif (!rawUrl) { try { rawUrl = $('\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 Drive').first().json.raw_url; } catch (e) {} }\n\nconst chatId = $('\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u0430').first().json.chatId;\n\nconst rows = $input.all().map(i => i.json).filter(r => r.day_number !== undefined && r.day_number !== '');\nconst maxDay = rows.length ? Math.max(...rows.map(r => Number(r.day_number) || 0)) : 0;\n\nreturn [{ json: {\n  day_number: maxDay + 1,\n  raw_url: rawUrl,\n  chat_id: chatId,\n  date_received: new Date().toISOString(),\n  total_days: Number($env.CHALLENGE_TOTAL_DAYS || 200)\n} }];"
      },
      "id": "a-next-day",
      "name": "\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        380,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GOOGLE_SHEETS_ID }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "pipeline"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "day_number": "={{ $json.day_number }}",
            "date_received": "={{ $json.date_received }}",
            "raw_url": "={{ $json.raw_url }}",
            "status": "received"
          },
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "a-sheets-append",
      "name": "\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        600,
        0
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.chat_id }}",
        "text": "=\u23f3 \u0420\u043e\u043b\u0438\u043a \u043f\u0440\u0438\u043d\u044f\u0442.\n\n\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 20% \u2014 \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u043d\u0435\u043c\u0435\u0446\u043a\u0438\u0439 (HeyGen)\u2026\n\u042d\u0442\u043e ~5\u201310 \u043c\u0438\u043d\u0443\u0442, \u0434\u0435\u0440\u0436\u0443 \u0432 \u043a\u0443\u0440\u0441\u0435.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "a-ack",
      "name": "\u0421\u0442\u0430\u0442\u0443\u0441: \u043f\u0440\u0438\u043d\u044f\u0442",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        820,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GOOGLE_SHEETS_ID }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "pipeline"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "day_number": "={{ $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.day_number }}",
            "tg_status_msg_id": "={{ $json.result ? $json.result.message_id : $json.message_id }}"
          },
          "matchingColumns": [
            "day_number"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "a-save-msgid",
      "name": "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c id \u0441\u0442\u0430\u0442\u0443\u0441\u0430",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        930,
        0
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.heygen.com/v2/video_translate",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "={{ $env.HEYGEN_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ video_url: $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.raw_url, output_language: $env.HEYGEN_OUTPUT_LANGUAGE || 'German', title: 'Tag ' + $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.day_number }) }}",
        "options": {}
      },
      "id": "a-heygen-start",
      "name": "HeyGen: \u043f\u0435\u0440\u0435\u0432\u043e\u0434",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1040,
        0
      ]
    },
    {
      "parameters": {
        "amount": 60
      },
      "id": "a-wait",
      "name": "\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 60 \u0441\u0435\u043a",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1260,
        0
      ]
    },
    {
      "parameters": {
        "url": "=https://api.heygen.com/v2/video_translate/{{ $('HeyGen: \u043f\u0435\u0440\u0435\u0432\u043e\u0434').first().json.data.video_translate_id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "={{ $env.HEYGEN_API_KEY }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a-heygen-status",
      "name": "HeyGen: \u0441\u0442\u0430\u0442\u0443\u0441",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1480,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "success",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "success"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "loose",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "failed",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "failed"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "pending"
        }
      },
      "id": "a-status-switch",
      "name": "\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        1700,
        0
      ]
    },
    {
      "parameters": {
        "errorMessage": "HeyGen: \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c failed"
      },
      "id": "a-heygen-failed",
      "name": "\u041e\u0448\u0438\u0431\u043a\u0430: HeyGen failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1920,
        140
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $runIndex }}",
              "rightValue": 40,
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a-timeout-check",
      "name": "\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1920,
        280
      ]
    },
    {
      "parameters": {
        "errorMessage": "HeyGen: \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0437\u0430 40 \u043c\u0438\u043d\u0443\u0442 (\u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u043f\u043e\u043b\u043b\u0438\u043d\u0433\u0430)"
      },
      "id": "a-timeout-error",
      "name": "\u041e\u0448\u0438\u0431\u043a\u0430: \u0442\u0430\u0439\u043c\u0430\u0443\u0442 HeyGen",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        2140,
        360
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.data.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "a-download-translated",
      "name": "\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1920,
        -140
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "name": "=day_{{ $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.day_number }}_translated.mp4",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GDRIVE_FOLDER_TRANSLATED }}"
        },
        "options": {}
      },
      "id": "a-drive-translated",
      "name": "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (translated)",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        2140,
        -140
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 10000
    },
    {
      "parameters": {
        "operation": "share",
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        },
        "options": {}
      },
      "id": "a-share-translated",
      "name": "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f (translated)",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        2360,
        -140
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GOOGLE_SHEETS_ID }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "pipeline"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "day_number": "={{ $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.day_number }}",
            "translated_url": "=https://drive.usercontent.google.com/download?export=download&confirm=t&id={{ $('\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (translated)').first().json.id }}",
            "status": "editing"
          },
          "matchingColumns": [
            "day_number"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "a-sheets-translated",
      "name": "\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c: translated",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2580,
        -140
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.submagic.co/v1/projects",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $env.SUBMAGIC_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Tag ' + $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.day_number, language: 'de', videoUrl: 'https://drive.usercontent.google.com/download?export=download&confirm=t&id=' + $('\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (translated)').first().json.id, templateName: $env.SUBMAGIC_TEMPLATE, webhookUrl: $env.SUBMAGIC_WEBHOOK_URL, magicZooms: false, magicBrolls: false, removeBadTakes: false }) }}",
        "options": {}
      },
      "id": "a-submagic",
      "name": "Submagic: \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2800,
        -140
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.GOOGLE_SHEETS_ID }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "pipeline"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "day_number": "={{ $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.day_number }}",
            "submagic_project_id": "={{ $json.id }}"
          },
          "matchingColumns": [
            "day_number"
          ],
          "schema": []
        },
        "options": {}
      },
      "id": "a-sheets-submagic",
      "name": "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c submagic_project_id",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        3020,
        -140
      ]
    },
    {
      "parameters": {
        "operation": "editMessageText",
        "chatId": "={{ $('\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f').first().json.chat_id }}",
        "messageId": "={{ $('\u0421\u0442\u0430\u0442\u0443\u0441: \u043f\u0440\u0438\u043d\u044f\u0442').first().json.result ? $('\u0421\u0442\u0430\u0442\u0443\u0441: \u043f\u0440\u0438\u043d\u044f\u0442').first().json.result.message_id : $('\u0421\u0442\u0430\u0442\u0443\u0441: \u043f\u0440\u0438\u043d\u044f\u0442').first().json.message_id }}",
        "text": "=\u23f3 \u0420\u043e\u043b\u0438\u043a \u0432 \u0440\u0430\u0431\u043e\u0442\u0435\n\n\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591 60% \u2014 \u041c\u043e\u043d\u0442\u0430\u0436: \u0441\u0443\u0431\u0442\u0438\u0442\u0440\u044b, \u0437\u0443\u043c\u044b, \u043f\u0430\u0443\u0437\u044b (Submagic)\u2026",
        "additionalFields": {
          "appendAttribution": false
        },
        "messageType": "message"
      },
      "id": "a-progress-edit",
      "name": "\u041f\u0440\u043e\u0433\u0440\u0435\u0441\u0441: \u043c\u043e\u043d\u0442\u0430\u0436",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        3240,
        -140
      ],
      "onError": "continueRegularOutput",
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 3000
    }
  ],
  "connections": {
    "\u0417\u0430\u043f\u0443\u0441\u043a \u0438\u0437 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430": {
      "main": [
        [
          {
            "node": "\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u0430",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u0430": {
      "main": [
        [
          {
            "node": "\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f": {
      "main": [
        [
          {
            "node": "TG getFile (local)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 Drive",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0430\u0439\u043b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u043f\u0440\u0438\u0448\u043b\u0438 \u0432\u0438\u0434\u0435\u043e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TG getFile (local)": {
      "main": [
        [
          {
            "node": "\u041f\u0443\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442\u0435",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041f\u0443\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442\u0435": {
      "main": [
        [
          {
            "node": "\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0427\u0438\u0442\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0441 \u0434\u0438\u0441\u043a\u0430": {
      "main": [
        [
          {
            "node": "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (raw)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (raw)": {
      "main": [
        [
          {
            "node": "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f (raw)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f (raw)": {
      "main": [
        [
          {
            "node": "raw_url \u0438\u0437 Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "raw_url \u0438\u0437 Drive": {
      "main": [
        [
          {
            "node": "\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 Drive": {
      "main": [
        [
          {
            "node": "\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443": {
      "main": [
        [
          {
            "node": "\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0434\u043d\u044f": {
      "main": [
        [
          {
            "node": "\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443": {
      "main": [
        [
          {
            "node": "\u0421\u0442\u0430\u0442\u0443\u0441: \u043f\u0440\u0438\u043d\u044f\u0442",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0421\u0442\u0430\u0442\u0443\u0441: \u043f\u0440\u0438\u043d\u044f\u0442": {
      "main": [
        [
          {
            "node": "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c id \u0441\u0442\u0430\u0442\u0443\u0441\u0430",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c id \u0441\u0442\u0430\u0442\u0443\u0441\u0430": {
      "main": [
        [
          {
            "node": "HeyGen: \u043f\u0435\u0440\u0435\u0432\u043e\u0434",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HeyGen: \u043f\u0435\u0440\u0435\u0432\u043e\u0434": {
      "main": [
        [
          {
            "node": "\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 60 \u0441\u0435\u043a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 60 \u0441\u0435\u043a": {
      "main": [
        [
          {
            "node": "HeyGen: \u0441\u0442\u0430\u0442\u0443\u0441",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HeyGen: \u0441\u0442\u0430\u0442\u0443\u0441": {
      "main": [
        [
          {
            "node": "\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u0430": {
      "main": [
        [
          {
            "node": "\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u041e\u0448\u0438\u0431\u043a\u0430: HeyGen failed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430": {
      "main": [
        [
          {
            "node": "\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 60 \u0441\u0435\u043a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u041e\u0448\u0438\u0431\u043a\u0430: \u0442\u0430\u0439\u043c\u0430\u0443\u0442 HeyGen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e": {
      "main": [
        [
          {
            "node": "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (translated)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Drive (translated)": {
      "main": [
        [
          {
            "node": "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f (translated)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f (translated)": {
      "main": [
        [
          {
            "node": "\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c: translated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c: translated": {
      "main": [
        [
          {
            "node": "Submagic: \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submagic: \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442": {
      "main": [
        [
          {
            "node": "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c submagic_project_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c submagic_project_id": {
      "main": [
        [
          {
            "node": "\u041f\u0440\u043e\u0433\u0440\u0435\u0441\u0441: \u043c\u043e\u043d\u0442\u0430\u0436",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b": {
      "main": [
        [
          {
            "node": "\u0427\u0438\u0442\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0441 \u0434\u0438\u0441\u043a\u0430",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}