Seithx/google-recorder-cli
GitHub: Seithx/google-recorder-cli
一个通过逆向 gRPC-Web API 从 Google Recorder 云端批量下载录音转录和音频的命令行工具。
Stars: 0 | Forks: 0
# Recorder CLI
CLI 工具,用于通过 gRPC-Web API 从 [Google Recorder](https://recorder.google.com) 下载转录文本和音频。
Google Recorder 是 Pixel 手机上的一款语音录制应用,可自动转录录音并将其同步到云端。此工具允许您从命令行下载转录文本和音频文件。
## 功能特性
- 列出和搜索录音
- 下载单个或批量转录文本(包含说话人标签)
- 下载音频文件 (m4a)
- 输出纯文本或 JSON 格式
- 带有时间戳的说话人标记转录片段
- 多账户支持
- 持久化认证(基于文件的 cookie 存储)
## 前置条件
- **Node.js** 18+
- 已安装 **Google Chrome**
- 拥有 Recorder 数据的 **Google 账户**(从 Pixel 手机同步)
## 安装设置
```
npm install
```
全局安装:
```
npm link
```
或直接运行:
```
node cli.js
```
## 身份验证
该工具需要来自 Chrome 的 Google cookie 进行身份验证。首次运行时,Chrome 会使用持久化配置文件打开,供您登录。
```
# 交互式认证(启动 Chrome,您登录一次)
node cli.js auth
# 使用特定账户索引(适用于多账户用户)
node cli.js auth --authuser 1
# 检查认证是否仍然有效
node cli.js auth --check
# 清除保存的凭证
node cli.js auth --clear
```
### 认证工作原理
```
CLI starts
|
Check saved credentials (file-based)
|-- Valid --> Use immediately (no Chrome needed)
|-- Expired/missing --> Connect to Chrome on port 9222
|-- Connected --> Extract fresh cookies
|-- Not connected --> Launch Chrome with persistent profile
|-- Session exists --> Auto-logged in
|-- No session --> Prompt login, wait
```
凭据保存至:`~/.config/recorder-cli/auth.json`
Chrome 配置文件存储于:`%LOCALAPPDATA%\recorder-cli\chrome-profile`
## 命令
### `list` - 列出最近的录音
```
node cli.js list
node cli.js list --limit 50
node cli.js list --json
```
### `info ` - 显示录音详情
```
node cli.js info
node cli.js info --json
```
### `transcript ` - 下载转录文本
```
# 打印到 stdout
node cli.js transcript
# 保存到文件
node cli.js transcript -o transcript.txt
# JSON 输出(包含说话人片段和时间)
node cli.js transcript --json
# 纯文本(无说话人标签)
node cli.js transcript --plain
```
### `audio ` - 下载音频
```
# 使用服务器提供的文件名下载
node cli.js audio
# 保存到特定文件
node cli.js audio -o meeting.m4a
```
### `search ` - 按标题搜索录音
```
node cli.js search "meeting notes"
node cli.js search "meeting" --limit 5
node cli.js search "meeting" --json
```
### `download` - 批量下载转录文本
```
node cli.js download
node cli.js download -o ./transcripts
node cli.js download --limit 100
node cli.js download --since 2025-01-01
node cli.js download --skip-existing
node cli.js download --format json
node cli.js download -o ./transcripts --limit 50 --since 2025-12-01 --skip-existing
```
### `download-audio` - 批量下载音频文件
```
node cli.js download-audio
node cli.js download-audio -o ./audio
node cli.js download-audio --limit 10
node cli.js download-audio --since 2025-01-01 --skip-existing
```
### `config` - 显示配置
```
node cli.js config
```
## 转录格式
### 文本格式 (默认)
```
Recording: Feb 5 at 12:07 PM
Date: 2/5/2026, 12:07:30 PM
Duration: 33:12
ID: bf3451e0-4ea6-424e-8e77-fbef4c0fe17c
=== Transcript ===
[Speaker 1] (00:00)
Hello, welcome to today's meeting...
[Speaker 2] (01:23)
Thanks for having me...
```
### JSON 格式
```
{
"recording": {
"id": "bf3451e0-...",
"title": "Feb 5 at 12:07 PM",
"date": "2026-02-05T22:07:30.207Z",
"duration": "33:12"
},
"transcript": {
"segments": [
{
"speaker": "Speaker 1",
"text": "Hello, welcome to today's meeting...",
"startTime": "00:00"
}
],
"rawText": "..."
}
}
```
## API Endpoints
协议:gRPC-Web over HTTPS POST | `Content-Type: application/json+protobuf` | 认证:`SAPISIDHASH` header + Google API key
**重要**:读取方法使用 Web 共享 UUID (`shareId`)。写入/变更方法使用设备内部 ID (`internalId`)。两者均由 `GetRecordingInfo` 返回。
### PlaybackService (16 种方法)
Host:`pixelrecorder-pa.clients6.google.com`
| Method | Body | Returns | Status |
|--------|------|---------|--------|
| `GetRecordingList` | `[[timestamp_s, ns], pageSize]` | 录音元数据数组 | 已实现 |
| `GetRecordingInfo` | `[shareId]` | 单个录音元数据 | 已实现 |
| `GetTranscription` | `[shareId]` | 带时间戳的词级转录文本 | 已实现 |
| `GetAudioTag` | `[shareId]` | 语音/音乐/静音片段 | 已实现 |
| `GetWaveform` | `[shareId]` | 波形振幅数据 | 已实现 |
| `ListLabels` | `[]` | 用户标签 | 已实现 |
| `GetShareList` | `[shareId]` | 共享权限 | 已实现 |
| `GetGlobalSearchReadiness` | `[]` | 搜索索引状态 | 已实现 |
| `Search` | `[query, null, shareId, null, limit]` | 录音匹配结果(分页) | 尚未实现 |
| `SingleRecordingSearch` | `[query, shareId]` | 单个录音内的匹配 | 尚未实现 |
| `UpdateRecordingLabels` | `[shareId, [["label", action]]]` | - | 尚未实现 |
| `DeleteRecordingList` | `[[internalId]]` | `[1]` | 尚未实现 |
| `ChangeShareState` | `[internalId, state]` | `[state, shareId]` | 尚未实现 |
| `UpdateRecordingTitle` | *(在源码中,未被触发)* | - | 尚未实现 |
| `WriteShareList` | *(在源码中)* | - | 尚未实现 |
| `BlockPerson` | *(在源码中)* | - | 尚未实现 |
### EditingService (9 种方法)
基于会话:`OpenSession` -> edits -> `SaveAudio` (创建副本) 或 `CloseSession` (丢弃)
| Method | Body | Returns | Status |
|--------|------|---------|--------|
| `OpenSession` | `[shareId]` | `[sessionId]` | 尚未实现 |
| `CropAudio` | `[sessionId, [[start_ns], [end_sec]]]` | 更新后的元数据 | 尚未实现 |
| `RemoveAudio` | `[sessionId, [[start_ns, end_ns], [end_sec]]]` | 更新后的元数据 | 尚未实现 |
| `UndoEdit` | `[sessionId]` | 更新后的元数据 | 尚未实现 |
| `SaveAudio` | `[sessionId, "title"]` | `[newRecordingId, 1]` | 尚未实现 |
| `CloseSession` | `[sessionId]` | `[]` | 尚未实现 |
| `SplitTranscription` | *(在源码中)* | - | 尚未实现 |
| `RenameSpeaker` | *(在源码中)* | - | 尚未实现 |
| `SwitchSpeaker` | *(在源码中)* | - | 尚未实现 |
### 音频下载
`GET https://usercontent.recorder.google.com/download/playback/{id}?authuser={N}&download=true` (m4a,支持范围请求)
## 项目结构
```
cli.js CLI entry point (commander.js)
src/
auth.js Auth management (Chrome, cookies, SAPISIDHASH, file persistence)
api.js Recorder API client (gRPC-Web + audio download)
tools/ Dev utilities (a11y snapshots, etc.)
```
## 故障排除
### "Not authenticated" 错误
运行 `node cli.js auth` 以设置或刷新您的 cookie。
### "AUTH_EXPIRED: 401"
您的 cookie 已过期。请重新认证:`node cli.js auth`
### "AUTH_EXPIRED: 403"
账户索引错误。尝试:`node cli.js auth --authuser 1`
### "Audio not found (404)"
刷新 cookie。音频使用不同的 endpoint,可能对 cookie 的新鲜度更敏感。
### 未显示录音
确保录音已同步到云端 [recorder.google.com](https://recorder.google.com)。
### "Invalid recording ID format"
ID 必须是 UUID。使用 `node cli.js list` 查找有效 ID。
## 致谢
灵感来源于 Dylan Moore 的 [google-recorder-cli](https://github.com/dylantmoore/google-recorder-cli),这是一个 TypeScript 实现,使用 Playwright 进行浏览器认证,并使用 `better-sqlite3` 直接提取 Chrome cookie。本项目以纯 JavaScript 配合 `puppeteer-core` 重新实现了这一概念,增加了基于文件的认证持久化,并指向不同的目标:通过 Gemini 为希伯来语转录和摘要构建自动化 pipeline。
## 作者
由 [Asaf Lecht](https://github.com/Seithx) 构建
## 许可证
ISC
标签:API 逆向, Chrome 自动化, Cookie 认证, GNU通用公共许可证, Google Recorder, gRPC-Web, MITM代理, Node.js, Pixel 手机, 二进制发布, 云端数据提取, 云资产清单, 开源工具, 录音下载, 批量下载, 数据同步, 自定义脚本, 语音转文字, 说话人分离, 转录导出, 逆向工程, 音频处理