npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hankei6km/gas-gocr2notion

v0.1.0

Published

TypeScript definitions for gas library @hankei6km/gas-gocr2notion

Downloads

4

Readme

gas-gocr2notion

Google Drive で OCR を行い、結果を Notion データベースへ送信する Google Apps Script ライブラリー。

Setup

ライブラリーは App Script で利用できる状態になっています。 Apps Script のコードエディターで以下の手順を実行するとプロジェクトへ追加できます。

  1. コードエディターのファイル名一覧が表示される部分の「ライブラリ +」をクリック
  2. 「スクリプト ID」フィールドに 1phsqy39NYEBOCpGx062N9kezLOdyzRKSEgDBYt6f-zaqVdAOdn9NaWWH を入力し検索をクリック
  3. バージョンを選択(通常は最新版)
  4. 「ID」を GocrToNotion へ変更
  5. 「追加」をクリック

上記以外にも Release ページから gas-gocr2notion.zip をダウンロードし、/dist ディレクトリーをプロジェクトへコピーできます。

Usage

Google Drive の特定のフォルダーに保存してあるファイルに OCR を行い、結果を Notion のデータベースへ送信する方法です。

Notion 側での手順

データベースを作成

OCR の結果が送信されるデータベースを用意します。プロパティは標準の状態のままで追加する必要はありません。

Notion インテグレーションを作成

Notion 外部からデータベースを操作するためのインテグレーション(API KEY)が必要です。以下を参考に作成してください。

インテグレーションへの許可

以下を参考に、用意したデータベースをインテグレーションと共有してください。

Google Drive 側での手順

スキャンされたファイルが保存されるフォルダー

スマートフォンでスキャン(カメラ撮影)した PDF などが保存されるフォルダーを作成します。 作成したらフォルダーの ID をメモしておいてください。

Google Apps Script で実行

スタンドアロンのスクリプトを作成し、以下の手順を実行してください。

  1. 「Setup」の手順でライブラリーを追加
  2. スクリプトファイルへ以下のようなコードを追加
    • notion_api_key にはインテグレーションの API KEY を記述
    • database_id には用意したデータベースの ID を記述
    • folder_id には作成したフォルダーの ID を記述
function myFunction() {
  const apiKey = 'notion_api_key'
  const database_id = 'database_id'
  const folder_id = 'folder_id'

  const opts = {
    database_id,
    ocrOpts: [
      {
        scanFolderId: folder_id,
        ocrFolderId: folder_id,
        ocrLanguage: 'ja',
        tags: [],
        removeOcrFile: true
      }
    ]
  }

  GocrToNotion.ocr(apiKey, opts)
}

OCR を行う

用意した Google Drive のフォルダーに PDF もしくは画像ファイルを保存します。

例) スマートフォンの Google Drive アプリでスキャン(カメラ利用)する。

この状態でスクリプトエディターから myFunction を実行すると OCR 処理が開始されます。

付録

追加設定などで他の機能を利用できます。

データベースのプロパティ

Notion のデータベースに以下のプロパティを追加することで OCR のテキスト送信時にそれぞれの値がセットされます。 プロパティは必要なもののみ追加できます。

| プロパティ名 | プロパティの種類 | 内容 | | -------------- | ---------------- | -------------------------------- | | entryUpdated | 日付 | データベースのエントリー更新日時 | | guid | テキスト | ファイルの id | | mimeType | セレクト | ファイルの mimeType | | type | セレクト | ファイルの種類 | | tags | マルチセレクト | OCR オプションで指定したタグ | | タグ | マルチセレクト | OCR オプションで指定したタグ | | excerpt | テキスト | OCR テキストの先頭 1900 バイト | | description | テキスト | ファイルの説明 | | link | URL | ファイルへのリンク | | modified | 日付 | ファイル更新日時 |

send() メソッド

ocr() のかわりに send() を使うことで Google Drive の変更通知から OCR 処理を開始できます。

これによりスマートフォンでスキャン後、短い待ち時間で Notion へテキストを追加できます。

Google Apps Script で変更通知を扱う方法については以下の記事などを参照してください。

参考

Google Drive で OCR 行う方法は以下の記事を参考にしました。

License

MIT License

Copyright (c) 2022 hankei6km