---
id: gh-douban-sync-skill
name: "douban-sync-skill"
url: https://skills.yangsir.net/skill/gh-douban-sync-skill
author: cosformula
domain: lifestyle
tags: ["douban", "data-sync", "export", "csv", "personal-data"]
install_count: 29
rating: 4.00 (20 reviews)
github: https://github.com/cosformula/douban-sync-skill
---

# douban-sync-skill

> 导出并同步豆瓣个人收藏（书籍、影视、音乐、游戏）到本地CSV文件。该技能帮助用户管理和备份豆瓣数据，支持增量同步，方便在Obsidian等工具中整理个人阅读、观影、听歌和游戏历史，实现数据本地化和自动化更新，告别手动记录的繁琐。

**Stats**: 29 installs · 4.0/5 (20 reviews)

## Before / After 对比

### 豆瓣收藏数据本地化与同步

**Before**:

以前手动记录或截图豆瓣收藏，数据分散且难以整理，无法方便地在本地进行管理和分析，更新耗时耗力，容易遗漏最新动态。

**After**:

现在通过自动化脚本将豆瓣收藏导出为CSV，并每日增量同步，数据统一存储，便于在Obsidian等工具中高效管理和回顾，确保数据最新且易于检索。

| Metric | Before | After | Change |
|---|---|---|---|
| 数据整理时间 | 30分钟 | 5分钟 | -83% |

## Readme

---
name: douban-sync
description: Export and sync Douban (豆瓣) book/movie/music/game collections to local CSV files (Obsidian-compatible). Use when the user wants to export their Douban reading/watching/listening/gaming history, set up incremental sync via RSS, or manage their Douban data locally.
metadata: {"openclaw": {"requires": {"env": ["DOUBAN_USER"]}, "primaryEnv": "DOUBAN_USER"}}
---

# Douban Sync

Export Douban collections (books, movies, music, games) to CSV and keep them in sync via RSS.

## Two Modes

### 1. Full Export (first time)

Use the browser tool to scrape all collection pages. Requires the user to be logged into Douban.

```
browser → douban.com/people/{USER_ID}/{category}?start=0&sort=time&mode=list
```

Categories and URL paths:
- Books: `book.douban.com/people/{ID}/collect` (读过), `/do` (在读), `/wish` (想读)
- Movies: `movie.douban.com/people/{ID}/collect` (看过), `/do` (在看), `/wish` (想看)
- Music: `music.douban.com/people/{ID}/collect` (听过), `/do` (在听), `/wish` (想听)
- Games: `www.douban.com/people/{ID}/games?action=collect` (玩过), `=do` (在玩), `=wish` (想玩)

Each page shows up to 30 items in list mode (some pages may have fewer due to delisted entries). Paginate with `?start=0,30,60...` — the script uses the paginator's "next" button to determine whether to continue.

**Rate limiting:** Wait 2-3 seconds between pages. If blocked, wait 30 seconds and retry.

**Scripts:**
- `scripts/douban-scraper.mjs` — HTTP-only, no browser needed (may get rate-limited)
- `scripts/douban-browser-scraper.mjs` — via Puppeteer CDP, needs a running browser
- `scripts/douban-extract.mjs` — generates a browser console script for manual extraction

### 2. Incremental Sync (daily, via RSS)

Run `scripts/douban-rss-sync.mjs` — no login needed.

```bash
node scripts/douban-rss-sync.mjs
```

**Setup:** Set environment variables:
- `DOUBAN_USER` (required): Douban user ID
- `DOUBAN_OUTPUT_DIR` (optional): Output root directory, default `~/douban-sync`

**Recommended:** Add a daily cron job for automatic sync.

## Output Format

Four CSV files per user in the output directory:

```
douban-sync/
└── {user_id}/
    ├── 书.csv
    ├── 影视.csv
    ├── 音乐.csv
    └── 游戏.csv
```

CSV columns:
```csv
title,url,date,rating,status,comment
"书名","https://book.douban.com/subject/12345/","2026-01-15","★★★★★","读过","短评内容"
```

- `status`: 读过/在读/想读, 看过/在看/想看, 听过/在听/想听, 玩过/在玩/想玩

## Deduplication

Both full export and RSS sync deduplicate by Douban URL — safe to run multiple times.

--- README.md ---

# douban-sync-skill

[![ClawHub](https://img.shields.io/badge/ClawHub-douban--sync--skill-blue?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEyIDJMMTMuMDkgOC4yNkwyMCA5TDEzLjA5IDE1Ljc0TDEyIDIyTDEwLjkxIDE1Ljc0TDQgOUwxMC45MSA4LjI2TDEyIDJaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K)](https://clawhub.ai/skills/douban-sync-skill)
[![ClawHub version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fclawhub.ai%2Fapi%2Fv1%2Fskills%2Fdouban-sync-skill&query=%24.skill.tags.latest&label=clawhub&prefix=v&color=blue)](https://clawhub.ai/skills/douban-sync-skill)
[![ClawHub downloads](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fclawhub.ai%2Fapi%2Fv1%2Fskills%2Fdouban-sync-skill&query=%24.skill.stats.downloads&label=clawhub%20downloads&color=blue)](https://clawhub.ai/skills/douban-sync-skill)
[![GitHub stars](https://img.shields.io/github/stars/cosformula/douban-sync-skill?style=flat&logo=github)](https://github.com/cosformula/douban-sync-skill)
[![License](https://img.shields.io/github/license/cosformula/douban-sync-skill)](./LICENSE)
[![CI](https://github.com/cosformula/douban-sync-skill/actions/workflows/ci.yml/badge.svg)](https://github.com/cosformula/douban-sync-skill/actions/workflows/ci.yml)
[![Publish to ClawHub](https://github.com/cosformula/douban-sync-skill/actions/workflows/clawhub-publish.yml/badge.svg)](https://github.com/cosformula/douban-sync-skill/actions/workflows/clawhub-publish.yml)

豆瓣书影音游戏标记数据导出与增量同步工具。支持全量导出和 RSS 增量同步，输出 CSV 格式。

可作为 [OpenClaw](https://github.com/openclaw/openclaw) / [AgentSkills](https://agentskills.io) 的 skill 使用，也可独立运行。

## 功能

- **全量导出**：抓取豆瓣个人主页的所有标记数据（书、影视、音乐、游戏）
- **增量同步**：通过 RSS 每日同步新标记，无需登录
- **CSV 输出**：结构化数据，方便导入 Excel/Obsidian/数据库
- **多用户支持**：按用户 ID 分目录存储
- **去重**：按 URL 去重，多次运行安全

## 输出格式

```
douban-sync/
└── {user_id}/
    ├── 书.csv
    ├── 影视.csv
    ├── 音乐.csv
    └── 游戏.csv
```

CSV 列：`title,url,date,rating,status,comment`

## 安装

### Via npx skills (any agent)

```bash
npx skills add cosformula/douban-sync-skill
```

### Via ClawHub (OpenClaw)

```bash
clawhub install douban-sync-skill
```

### Manual

```bash
git clone https://github.com/cosformula/douban-sync-skill.git
```

## 使用

### 增量同步（推荐日常使用）

```bash
DOUBAN_USER=your_douban_id node scripts/douban-rss-sync.mjs
```

环境变量：
- `DOUBAN_USER`（必填）：豆瓣用户 ID
- `DOUBAN_OUTPUT_DIR`（可选）：输出根目录，默认 `~/douban-sync`。文件会写入 `$DOUBAN_OUTPUT_DIR/$DOUBAN_USER/` 下

### 全量导出

```bash
# HTTP 直接抓取（可能被限速）
DOUBAN_USER=your_douban_id node scripts/douban-scraper.mjs

# 通过浏览器 CDP 抓取（需要 puppeteer-core + 已登录的浏览器）
DOUBAN_USER=your_douban_id node scripts/douban-browser-scraper.mjs
```

### 从 Markdown 迁移到 CSV

如果之前用的是 Markdown 格式的导出数据：

```bash
DOUBAN_USER=your_douban_id node scripts/migrate-md-to-csv.mjs
```

## 安全注意事项

- `douban-browser-scraper.mjs` 通过 CDP 连接本地浏览器（默认 `http://127.0.0.1:18800`），仅在你自己启动的本地浏览器上使用，不要暴露调试端口到网络
- 如果只需要增量同步，`douban-rss-sync.mjs` 不需要登录，风险最低

## 作为 OpenClaw Skill 使用

将此目录放在 OpenClaw workspace 的 `skills/` 下即可自动识别。

## License

MIT

---
*Source: https://skills.yangsir.net/skill/gh-douban-sync-skill*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-douban-sync-skill/markdown*