{
  "name": "Lesson 6 OCR",
  "nodes": [
    {
      "parameters": {
        "operation": "list",
        "useQueryString": true,
        "queryString": "parents in \"1eTCvzwIpllfTk0zPf0y8oG9E9lyNBjFu\" and name contains \".png\"",
        "options": {}
      },
      "id": "efcf123e-5786-46f2-9ae2-60aff2081f8c",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 2,
      "position": [
        -860,
        2480
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "14",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "id": "da193ba1-2916-46e1-ad30-d3514bbe0a91",
      "name": "Скачать файл",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 2,
      "position": [
        -880,
        1380
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "14",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "binaryData": true,
        "name": "=распознано_{{ $('Скачать файл').item.binary.data.fileName }}",
        "parents": [
          "1mjGomDZh_iNZV2b0MMzNzOCS0JELJ5r1"
        ],
        "options": {}
      },
      "id": "ede0eee6-cb62-4048-8389-670551997603",
      "name": "Закачать файл",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 2,
      "position": [
        -180,
        1380
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "14",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1eTCvzwIpllfTk0zPf0y8oG9E9lyNBjFu",
          "mode": "list",
          "cachedResultName": "Распознавание документов",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1eTCvzwIpllfTk0zPf0y8oG9E9lyNBjFu"
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "81ec2dd1-7b54-4de7-8f97-b1c84b3a43e5",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -1120,
        1380
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "14",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.ocr.space/parse/image",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            },
            {
              "name": "isCreateSearchablePdf",
              "value": "true"
            },
            {
              "name": "OCREngine",
              "value": "2"
            },
            {
              "name": "isSearchablePdfHideTextLayer",
              "value": "true"
            }
          ]
        },
        "options": {}
      },
      "id": "2b6147de-f7fe-4b42-bbc9-9a981bd4b43e",
      "name": "Распознать текст",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        -640,
        1380
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "27",
          "name": "OCR space Header Auth"
        }
      }
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "value": "b9e50cfc-8d55-4da5-b241-1bb7ab7526bb",
          "mode": "list",
          "cachedResultName": "Документы с OCR Space",
          "cachedResultUrl": "https://www.notion.so/b9e50cfc8d554da5b2411bb7ab7526bb"
        },
        "title": "={{ $json.name }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Ссылка|url",
              "urlValue": "=https://drive.google.com/file/d/{{ $json[\"id\"] }}/view"
            },
            {
              "key": "Файл|files",
              "fileUrls": {
                "fileUrl": [
                  {
                    "name": "={{ $json.name }}",
                    "url": "=https://drive.google.com/uc?id={{ $json[\"id\"] }}&export=download"
                  }
                ]
              }
            },
            {
              "key": "Содержимое|rich_text",
              "textContent": "={{ $node[\"Создать название файла\"].json.ParsedResults[0].ParsedText }}"
            }
          ]
        },
        "options": {}
      },
      "id": "b0f5c7f2-a5d7-45a3-bb7a-c21c63d48a3a",
      "name": "Добавить в Notion",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2,
      "position": [
        -380,
        2840
      ],
      "credentials": {
        "notionApi": {
          "id": "20",
          "name": "Notion account"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "content": "## Ресурсы\nДля фильтра Google Drive надо смотреть [Справку Google Drive по поисковым запросам](https://developers.google.com/drive/api/guides/ref-search-terms?hl=ru)\nID папки находится в конце ее ссылки:\ndrive.google. com/drive/u/0/folders/ID_папки",
        "width": 644.7350354124125
      },
      "id": "3c871c83-8956-47dc-a72d-384c53137010",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -680,
        2480
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "id": "9c7d6af8-6aa9-40ad-a9fb-be0f1114195f",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        -1100,
        2480
      ]
    },
    {
      "parameters": {
        "operation": "delete",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        }
      },
      "id": "ccd32252-d0cb-4ef8-b943-fd973e35e7a9",
      "name": "Удалить файл",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 2,
      "position": [
        -660,
        2840
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "14",
          "name": "Google Drive account"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "content": "## Справка по API распознавания\nhttps://ocr.space/ocrapi\n",
        "height": 94.59290802349972,
        "width": 409.39176054369625
      },
      "id": "f5fce057-3be9-41c2-b3bd-b216119074a3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -740,
        1140
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.ocr.space/Parse/Image",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "isOverlayRequired",
              "value": "true"
            },
            {
              "name": "language",
              "value": "eng"
            },
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            },
            {
              "name": "isCreateSearchablePdf",
              "value": "true"
            },
            {
              "name": "OCREngine",
              "value": "2"
            },
            {
              "name": "isSearchablePdfHideTextLayer",
              "value": "true"
            }
          ]
        },
        "options": {}
      },
      "id": "f02fc809-26fa-42dc-bf22-4853dbe4ef47",
      "name": "Распознать текст1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        -640,
        1600
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "27",
          "name": "OCR space Header Auth"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $json.SearchablePDFURL }}",
        "options": {}
      },
      "id": "fe9f7d56-1e4c-4f3d-acc3-f776f5753ac1",
      "name": "ПолучитьPDF по ссылке с текстовым слоем",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        -400,
        1380
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Скачать файл": {
      "main": [
        [
          {
            "node": "Распознать текст",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Скачать файл",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Распознать текст": {
      "main": [
        [
          {
            "node": "ПолучитьPDF по ссылке с текстовым слоем",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ПолучитьPDF по ссылке с текстовым слоем": {
      "main": [
        [
          {
            "node": "Закачать файл",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "versionId": "4c890b44-3f92-4453-9f86-24bdee95f57f",
  "id": "22",
  "meta": {
    "instanceId": "62148517c718afe88189b4557f5264eca24fb302b44a11226f98636805acbeef"
  },
  "tags": [
    {
      "id": "2",
      "createdAt": "2023-06-22T04:56:17.812Z",
      "updatedAt": "2023-06-22T04:56:17.812Z",
      "name": "n8n business course"
    }
  ]
}