本機自動化工具 macOS vs Windows 11:跨平台任務整合與 API 實戰

本機自動化工具對照表 macOS vs Windows 11

macOS 工具

工具名稱 是否內建 可錄製操作 可編輯邏輯 支援 Web 操作 可呼叫 API
Automator ✅ 是 ⚠️ 部分支援 ⚠️ 基本流程 ⚠️ 可搭配 Script
AppleScript ✅ 是 ✅(可錄製 GUI 操作) ⚠️ 透過 curl 可整合
Hammerspoon ❌(需安裝) ❌(純程式控制) ✅ 可寫全邏輯 ⚠️ 間接支援(需搭配 script) ✅ 完整支援 API 請求

Windows 工具

工具名稱 是否內建 可錄製操作 可編輯邏輯 支援 Web 操作 可呼叫 API
Power Automate Desktop ✅ 是(Pro/Enterprise) ✅ 支援完整錄製 ✅ 條件邏輯強 ✅ 支援 Web Automation ✅ 內建 HTTP 請求模組
AutoHotKey (AHK) ❌ 需安裝 ❌ 無錄製器(可手寫操作模擬) ⚠️ 需搭配瀏覽器自動化套件 ⚠️ 手動整合 API

📌 任務說明解析:

每日任務:

➤ 取得 YouTube 收藏影片
➤ 使用 Memo AI(AI 筆記工具)分析影片產出字幕
➤ 將字幕寫入 Notion


🎯 建議方案:

✅ 最佳選擇(跨平台):使用 Power Automate Desktop + API

  • 如果你在 Windows:這是最省力的方式
  • 可用「Web 自動化」登入 YouTube → 抓收藏清單 → 呼叫 Memo AI API 分析 → 用 HTTP 模組寫入 Notion

✅ macOS 使用者建議:Hammerspoon + AppleScript 組合

  • Hammerspoon 負責處理背景監控、API 傳送
  • AppleScript 負責 GUI 自動化(打開 YouTube、複製連結)
  • 若你會寫 Shell/JavaScript,可呼叫 curlfetch 把 Memo AI 結果寫入 Notion

🚀 進階整合建議(如果你願意架構這個工作流):

Step 1: 抓取 YouTube 收藏影片

  • macOS:用 AppleScript 自動控制 Safari / Chrome,複製影片網址
  • Windows:Power Automate Desktop 可自動開啟瀏覽器與操作

Step 2: 呼叫 Memo AI 產出字幕

  • 方式一:使用 API 傳送影片連結並取得字幕
  • 方式二:用剪貼簿監控工具自動提交網址給 Memo AI

Step 3: 寫入 Notion

  • 使用 Notion API(需建立 Integration Token)發送 POST 請求到指定資料庫
  • macOS 可透過 curl,Windows 可用 Power Automate 的 HTTP Request

🧑‍💻 如果你喜歡「不用寫太多程式」的方式:

  • Windows:選擇 Power Automate Desktop(搭配 Notion/Memo 的 API)
  • macOS:選擇 Keyboard Maestro + AppleScript(GUI 控制),或 Hammerspoon(程式控)

✅ 一、Windows 上的 Power Automate Desktop 流程草稿

目標流程:
每天自動打開 YouTube 收藏 → 抓連結 → 呼叫 Memo AI 分析 → 把字幕內容寫入 Notion


🧱 流程架構(模擬步驟):

1️⃣ 開啟 YouTube 收藏頁

  • 操作:
    • 使用「啟動網頁瀏覽器」
    • URL:https://www.youtube.com/playlist?list=WL(收藏清單)

2️⃣ 擷取最新影片的連結

  • 操作:
    • 用 UI 元素選取影片標題連結
    • 儲存到變數 youtubeUrl

3️⃣ 呼叫 Memo AI API 提取字幕

假設 Memo AI 支援以下 API 呼叫(範例):

POST https://api.memoai.dev/transcribe
{
  "video_url": "https://youtube.com/watch?v=xxxx"
}
  • 操作:
    • 使用「HTTP 要求」模組
    • 方法:POST
    • URL:https://api.memoai.dev/transcribe
    • 內容類型:application/json
    • 內容:
      {
        "video_url": "%youtubeUrl%"
      }
      
    • 結果存入變數:memoResult

4️⃣ 寫入 Notion(使用 Notion API)

  • 前置:
    • 建立 Integration Token 並取得資料庫 ID
  • 操作:
    • 使用另一個「HTTP 要求」模組
    • 方法:POST
    • URL:https://api.notion.com/v1/pages
    • Headers:
      • Authorization: Bearer YOUR_NOTION_TOKEN
      • Notion-Version: 2022-06-28
      • Content-Type: application/json
    • Body:
      {
        "parent": { "database_id": "YOUR_DATABASE_ID" },
        "properties": {
          "Title": {
            "title": [
              { "text": { "content": "來自 YouTube 的新筆記" } }
            ]
          }
        },
        "children": [
          {
            "object": "block",
            "type": "paragraph",
            "paragraph": {
              "text": [{ "type": "text", "text": { "content": "%memoResult%" } }]
            }
          }
        ]
      }
      

🖥️ 二、macOS 上的 curl + Notion API 腳本

1️⃣ 呼叫 Memo AI API 取得字幕

#!/bin/bash

YOUTUBE_URL="https://www.youtube.com/watch?v=YOUR_VIDEO_ID"

memo_response=$(curl -s -X POST https://api.memoai.dev/transcribe \
  -H "Content-Type: application/json" \
  -d "{\"video_url\":\"$YOUTUBE_URL\"}")

subtitles=$(echo "$memo_response" | jq -r '.transcription')

2️⃣ 寫入 Notion

NOTION_TOKEN="secret_xxxxxxxxxxxxx"
DATABASE_ID="xxxxxxxxxxxxxxxxxx"

curl -X POST https://api.notion.com/v1/pages \
  -H "Authorization: Bearer $NOTION_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Notion-Version: 2022-06-28" \
  -d "{
    \"parent\": { \"database_id\": \"$DATABASE_ID\" },
    \"properties\": {
      \"Title\": {
        \"title\": [
          { \"text\": { \"content\": \"YouTube 字幕紀錄\" } }
        ]
      }
    },
    \"children\": [
      {
        \"object\": \"block\",
        \"type\": \"paragraph\",
        \"paragraph\": {
          \"text\": [{ \"type\": \"text\", \"text\": { \"content\": \"$subtitles\" } }]
        }
      }
    ]
  }"

✅ 這段可以儲存為 .sh 腳本,然後用 macOS 的 AutomatorShortcuts 定時執行。


🔑 前置工具安裝(macOS)

安裝 jq(處理 JSON):

brew install jq

📦 延伸自動化

你可以使用 launchdcrontab 來每天執行這段腳本,或是搭配 Hammerspoon 設定快捷鍵、剪貼簿自動觸發。

定義一個適合這個任務的 Notion 資料庫欄位設定,可以直接用來存放從 Memo AI 取得的影片筆記與字幕內容。


📘 Notion 資料庫欄位設定建議

欄位名稱(Name) 類型 用途說明
影片標題 標題(Title) 必備欄位,用來顯示影片名稱
影片連結 網址(URL) 儲存該影片的 YouTube 網址
筆記內容 文字(Text) 來自 Memo AI 的字幕或總結文字
日期 日期(Date) 記錄建立時間,或影片上傳日
來源標籤 標籤(Multi-select) 可設為「YouTube」、「Memo AI」,方便分類
處理狀態 單選(Select) 例如「已完成」、「待整理」、「略過」等選項

🧱 Notion API 的對應 JSON 格式(範例)

{
  "parent": { "database_id": "YOUR_DATABASE_ID" },
  "properties": {
    "影片標題": {
      "title": [{ "text": { "content": "影片標題來自 Memo AI 或 YouTube" } }]
    },
    "影片連結": {
      "url": "https://www.youtube.com/watch?v=xxxx"
    },
    "日期": {
      "date": { "start": "2025-04-19" }
    },
    "來源標籤": {
      "multi_select": [{ "name": "YouTube" }, { "name": "Memo AI" }]
    },
    "處理狀態": {
      "select": { "name": "已完成" }
    }
  },
  "children": [
    {
      "object": "block",
      "type": "paragraph",
      "paragraph": {
        "text": [{ "type": "text", "text": { "content": "這是 Memo AI 的字幕內容" } }]
      }
    }
  ]
}

macOS 自動化腳本(可跑在 Shortcuts 或 Automator 中),每天自動把 YouTube 收藏影片透過 Memo AI 轉字幕,再寫入 Notion。以下是詳細步驟👇


✅ 步驟一:建立 Notion API Token 與資料庫設定

🔐 1. 建立 Notion Integration Token(第一次才需要做)

  1. 進入 https://www.notion.so/my-integrations
  2. 點選「+ New Integration
  3. 填寫名稱,例如:Memo Sync Bot
  4. 權限勾選:✅ Insert content、✅ Read content
  5. 建立後,複製 Internal Integration Token(開頭為 secret_...

📄 2. 分享 Notion 資料庫給此 Integration

  1. 開啟你的 Notion 資料庫頁面
  2. 點右上角「Share」→ 「Invite」→ 選擇剛剛的 Integration 名稱
  3. 點「Invite」即可授權存取

📘 3. 取得你的資料庫 ID

  • 在你的 Notion 資料庫頁面中,URL 會是這樣:
    https://www.notion.so/yourname/xxx?d=xxxxxxxxxxxxxxxxxxxx
    
  • 複製 xxx(或一段長長的 UUID,就是資料庫 ID)

🧱 步驟二:整合 curl 自動化腳本

#!/bin/bash

# --- 參數設定區 ---
NOTION_TOKEN="你的 secret_xxxxxxx"
DATABASE_ID="你的資料庫 ID"
YOUTUBE_URL="https://www.youtube.com/watch?v=xxxx"  # 可自動替換成剪貼簿內容
TODAY=$(date +"%Y-%m-%d")

# --- 使用 YouTube API 抓影片標題(可選) ---
# 或用 yt-dlp 工具也可以:
video_title=$(yt-dlp --get-title "$YOUTUBE_URL")

# --- 呼叫 Memo AI API ---
memo_response=$(curl -s -X POST https://api.memoai.dev/transcribe \
  -H "Content-Type: application/json" \
  -d "{\"video_url\":\"$YOUTUBE_URL\"}")

subtitles=$(echo "$memo_response" | jq -r '.transcription')

# --- 組合並發送 Notion API 請求 ---
curl -X POST https://api.notion.com/v1/pages \
  -H "Authorization: Bearer $NOTION_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Notion-Version: 2022-06-28" \
  -d "{
    \"parent\": { \"database_id\": \"$DATABASE_ID\" },
    \"properties\": {
      \"影片標題\": {
        \"title\": [{ \"text\": { \"content\": \"$video_title\" } }]
      },
      \"影片連結\": {
        \"url\": \"$YOUTUBE_URL\"
      },
      \"日期\": {
        \"date\": { \"start\": \"$TODAY\" }
      },
      \"來源標籤\": {
        \"multi_select\": [{ \"name\": \"YouTube\" }, { \"name\": \"Memo AI\" }]
      },
      \"處理狀態\": {
        \"select\": { \"name\": \"已完成\" }
      }
    },
    \"children\": [
      {
        \"object\": \"block\",
        \"type\": \"paragraph\",
        \"paragraph\": {
          \"text\": [{ \"type\": \"text\", \"text\": { \"content\": \"$subtitles\" } }]
        }
      }
    ]
  }"

🧰 安裝需要工具(第一次執行):

brew install jq yt-dlp

如果你不想用 yt-dlp,也可以改成從剪貼簿讀取影片標題(使用 osascript)。


🚀 步驟三:將 Shell Script 加入 macOS 自動化(兩種方法)

方式 1️⃣:用 Shortcuts.app 自動執行腳本

  1. 打開「捷徑 Shortcuts」→ 新增捷徑
  2. 加入「執行 Shell Script」
    /Users/你的帳號/Documents/memo-notion-sync.sh
    
  3. 設定為「每天執行」或加入 Finder 右鍵選單等方式

方式 2️⃣:用 Automator.app 建立 App 或服務

  1. 開啟 Automator → 建立「應用程式」或「快速動作」
  2. 搜尋 Shell Script,加入並貼上你的腳本
  3. 存檔後可當 App 雙擊執行,或設排程

🧠 補充進階(可選):

  • 使用 pbpaste 抓取剪貼簿影片連結:
    YOUTUBE_URL=$(pbpaste)
    
  • 使用 osascript 抓 Safari 目前網址:
    YOUTUBE_URL=$(osascript -e 'tell application "Safari" to return URL of front document')
    

以下是加入錯誤處理、變數校驗等的 完整範例,可打包成 .command 檔案,這樣你可以直接雙擊執行。


📝 完整範例腳本(含錯誤處理和變數校驗)

#!/bin/bash

# --- 參數設定區 ---
NOTION_TOKEN="你的 secret_xxxxxxx"
DATABASE_ID="你的資料庫 ID"
YOUTUBE_URL="https://www.youtube.com/watch?v=xxxx"  # 預設影片連結(可自動替換為剪貼簿)
TODAY=$(date +"%Y-%m-%d")

# --- 檢查必需的環境變數 ---
if [ -z "$NOTION_TOKEN" ]; then
  echo "錯誤:NOTION_TOKEN 變數未設定!"
  exit 1
fi

if [ -z "$DATABASE_ID" ]; then
  echo "錯誤:DATABASE_ID 變數未設定!"
  exit 1
fi

# --- 使用 YouTube API 抓影片標題(可選) ---
# 使用 yt-dlp 工具或其他方法抓取影片標題
if ! command -v yt-dlp &> /dev/null; then
  echo "錯誤:yt-dlp 未安裝!"
  exit 1
fi

video_title=$(yt-dlp --get-title "$YOUTUBE_URL")

if [ -z "$video_title" ]; then
  echo "錯誤:無法獲取影片標題!"
  exit 1
fi

echo "影片標題:$video_title"

# --- 呼叫 Memo AI API ---
memo_response=$(curl -s -X POST https://api.memoai.dev/transcribe \
  -H "Content-Type: application/json" \
  -d "{\"video_url\":\"$YOUTUBE_URL\"}")

# 檢查 API 回應
if [ $? -ne 0 ]; then
  echo "錯誤:呼叫 Memo AI API 失敗!"
  exit 1
fi

subtitles=$(echo "$memo_response" | jq -r '.transcription')

# 檢查字幕是否成功提取
if [ -z "$subtitles" ]; then
  echo "錯誤:無法從 Memo AI 獲取字幕!"
  exit 1
fi

echo "字幕內容:$subtitles"

# --- 組合並發送 Notion API 請求 ---
curl_response=$(curl -s -X POST https://api.notion.com/v1/pages \
  -H "Authorization: Bearer $NOTION_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Notion-Version: 2022-06-28" \
  -d "{
    \"parent\": { \"database_id\": \"$DATABASE_ID\" },
    \"properties\": {
      \"影片標題\": {
        \"title\": [{ \"text\": { \"content\": \"$video_title\" } }]
      },
      \"影片連結\": {
        \"url\": \"$YOUTUBE_URL\"
      },
      \"日期\": {
        \"date\": { \"start\": \"$TODAY\" }
      },
      \"來源標籤\": {
        \"multi_select\": [{ \"name\": \"YouTube\" }, { \"name\": \"Memo AI\" }]
      },
      \"處理狀態\": {
        \"select\": { \"name\": \"已完成\" }
      }
    },
    \"children\": [
      {
        \"object\": \"block\",
        \"type\": \"paragraph\",
        \"paragraph\": {
          \"text\": [{ \"type\": \"text\", \"text\": { \"content\": \"$subtitles\" } }]
        }
      }
    ]
  }")

# 檢查 Notion 回應
if [ $? -ne 0 ]; then
  echo "錯誤:發送資料至 Notion 失敗!"
  exit 1
fi

echo "成功將資料送入 Notion!"

💡 使用說明:

  1. 安裝工具:
    在執行之前,確保 yt-dlpjq 已安裝:
    brew install jq yt-dlp
    
  2. 設定 Notion Token 和資料庫 ID:
    在腳本中替換以下欄位:
    • NOTION_TOKEN="你的 secret_xxxxxxx"
    • DATABASE_ID="你的資料庫 ID"
  3. 確保影片連結正確:
    影片連結可以手動設定,也可以從剪貼簿或瀏覽器自動抓取。腳本目前以固定連結 https://www.youtube.com/watch?v=xxxx 為例。

📦 打包成 .command 檔案

步驟:

  1. 將腳本儲存為 .command 檔案:
    nano memo-notion-sync.command
    
    將上面的完整腳本貼進去,儲存並關閉。
  2. 賦予執行權限:
    chmod +x memo-notion-sync.command
    
  3. 雙擊執行:
    • 現在你可以直接雙擊 .command 檔案來執行此腳本,或將它放進自動化工具中定時執行。

📅 設定每天自動執行(使用 cron 排程)

步驟:

  1. 打開 Terminal,輸入:
    crontab -e
    
  2. crontab 中加入以下行(設定每天早上 7 點執行):
    0 7 * * * /path/to/memo-notion-sync.command
    
  3. 儲存並退出。

⛅ 進階選項(可選):

  • 你可以將 .command 檔案轉為應用程式(.app),並利用 Automator 創建自動執行的應用程式,或與 Shortcuts 配合。