1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Meet の URL をショートカットで自動生成する方法

Posted at

恐ろしいほど生活が豊かになったので共有です。

挙動

  1. 特定のショートカットキーを入力
  2. AppleScript が検知し、デプロイされた GAS を実行
  3. GAS から、Google Meet REST API を叩く
  4. GAS から生成されたリンクを AppleScript に返す
  5. AppleScript からクリップボードにリンクをコピーする

作り方

1. GAS のコードを記入

/**
 * Google Meet の会議スペースを作成して URL を返す
 * Web アプリとしてデプロイすれば、ブラウザに meetingUri を表示します
 */
function doGet() {
  const url = 'https://meet.googleapis.com/v2/spaces';
  const payload = {}; // 何も指定しない最小作成。必要に応じて SpaceConfig を指定可能
  const options = {
    method: 'post',
    contentType: 'application/json',
    headers: {
      // ScriptApp のトークンはスコープによりアクセス不可の場合あり
      Authorization: 'Bearer ' + ScriptApp.getOAuthToken()
    },
    // JSON の文字列を payload に入れる
    payload: JSON.stringify(payload),
    muteHttpExceptions: true
  };

  try {
    const response = UrlFetchApp.fetch(url, options);
    const status = response.getResponseCode();
    const resultText = response.getContentText();

    // ログ用
    console.log('Status: ' + status);
    console.log('Response: ' + resultText);

    // 成功時は Space リソースが返る。meetingUri が含まれている
    const data = JSON.parse(resultText);

    if (data.meetingUri) {
      console.log('生成されたURL: ' + data.meetingUri);
      return ContentService.createTextOutput(data.meetingUri);
    } else {
      // エラーやフィールド名の差異に備えて可視化
      return ContentService.createTextOutput('Error detail: ' + resultText);
    }
  } catch (e) {
    console.log('システムエラー: ' + e.toString());
    return ContentService.createTextOutput('Catch error: ' + e.toString());
  }
}

2. GAS , GCP を設定

  • GAS > プロジェクトの設定 > Google Cloud Platformプロジェクト
    → GCP のプロジェクトを指定
  • 指定した GCP のプロジェクト内で Meet REST API を有効化

3. AppleScript を設定

  • 画像のように設定
  • URLの内容を取得の "URL" の部分に GAS のデプロイ URL を記入
  • ショートカットキーを設定

image.png

on run {input, parameters}
   delay 0.3
   tell application "System Events" to keystroke "v" using command down
   return input
end run

image.png

終了

本当に楽になったので、お勧めです。
お読みいただき、ありがとうございました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?