Handles interactions with the dedao-dl CLI tool for downloading and managing content from the Dedao (得到) App. Use when the user wants to list bought courses,...
---
name: dedao-dl
description: Handles interactions with the dedao-dl CLI tool for downloading and managing content from the Dedao (得到) App. Use when the user wants to list bought courses, ebooks, audiobooks, or download them in various formats (PDF, MP3, Markdown, EPUB).
---
# dedao-dl
This skill guides the agent in using the `dedao-dl` CLI tool to interact with the Dedao (得到) app content.
## Initialization
**MANDATORY FIRST STEP:** Before using any `dedao-dl` commands for the first time, you MUST run the installation script and verify the CLI is available.
Run the script to download the latest binary for the current OS:
```bash
python scripts/install_dedao_dl.py
```
After installation, you should ALWAYS use the helper script `scripts/run_dedao.py` to execute commands instead of running the raw `dedao-dl` executable. The helper script cleans up the CLI's terminal formatting, making the output directly readable by you without needing to redirect it to text files.
Example: Use `python scripts/run_dedao.py -h` instead of `./dedao-dl -h`.
## Prerequisites & Login
Before downloading any content, ensure the user is logged in:
- Command: `python scripts/run_dedao.py login -q` (QR code login) or `python scripts/run_dedao.py login -c "<cookie_string>"`
- Verify current user: `python scripts/run_dedao.py who`
- List logged-in users: `python scripts/run_dedao.py users`
- Switch user: `python scripts/run_dedao.py su`
Dependencies for specific formats (inform the user if they are missing):
- PDF generation requires `wkhtmltopdf`
- Audio generation requires `ffmpeg`
- Markdown requires no additional dependencies
## General Workflow
For any content download, the typical two-step workflow is:
1. List the specific type of content to find its `ID`.
2. Use the corresponding download command with the `ID` and format flag (`-t`).
## Key Workflows & Commands
### 1. Courses (专栏/课程) & Free Content (免费专区)
- **List purchased courses**: `python scripts/run_dedao.py course`
- **List free courses**: `python scripts/run_dedao.py free` (Returns `EnID` strings instead of integer `ID`s)
- **List articles in a course**:
- For purchased courses (using integer ID): `python scripts/run_dedao.py course -i <course_ID>`
- For free courses (using EnID): `python scripts/run_dedao.py article -c <course_EnID>`
- **Download a single article (RECOMMENDED)**: `python scripts/run_dedao.py dl <course_ID_or_EnID> <article_ID> -t <format>`
- **Download a full course**: `python scripts/run_dedao.py dl <course_ID_or_EnID> -t <format> [options]`
- **WARNING: NEVER download a full course (only 1 parameter) without explicit user permission. Full downloads can take hours, consume massive disk space, and trigger anti-bot bans.**
- Formats (`-t`): `1` (MP3), `2` (PDF), `3` (Markdown, **DEFAULT FOR THE AGENT**)
- Options for Markdown (`-t 3`): `-m` (merge into one file), `-c` (include hot comments)
- Prefix ordering: `-o` (adds index prefix like `00x.`)
*Note: When downloading as PDF, be aware of rate limits ("496 NoCertificate"). Add sleep intervals if scripting.*
### 2. E-Books (电子书)
- **List e-books**: `python scripts/run_dedao.py ebook`
- **Download an e-book**: `python scripts/run_dedao.py dle <ebook_ID> -t <format>`
- Formats (`-t`): `1` (HTML, default), `2` (PDF), `3` (EPUB), `4` (Markdown Notes)
- **View e-book notes**: `python scripts/run_dedao.py ebook notes -i <ebook_ID>`
- **Export e-book notes**: `python scripts/run_dedao.py dle <ebook_ID> -t 4` (Downloads notes as Markdown)
### 3. Audiobooks (每天听本书)
- **List audiobooks**: `python scripts/run_dedao.py odob`
- **Download audiobook audio/text**: `python scripts/run_dedao.py dlo <audiobook_ID> -t <format>`
- Formats (`-t`): `1` (MP3), `2` (PDF), `3` (Markdown, **DEFAULT FOR THE AGENT**)
### 4. Other Content
- **List all categories & stats**: `python scripts/run_dedao.py cat`
- **List 'JinNang' (锦囊)**: `python scripts/run_dedao.py ace`
- **List recommended topics (知识城邦)**: `python scripts/run_dedao.py topic`
## Execution Guidelines
- Always check `python scripts/run_dedao.py -h` or `python scripts/run_dedao.py <command> -h` if unsure of the exact arguments.
- Always retrieve the correct `ID` first before executing a download command. **Make sure you use the list command corresponding to the content type you want to download (e.g., `course` ID for `dl`, `ebook` ID for `dle`, `odob` ID for `dlo`). Do not mix up IDs across categories.**
- **NEVER download an entire course (e.g. `python scripts/run_dedao.py dl <course_ID_or_EnID>`) unless the user explicitly asks you to.** Many courses have hundreds of articles which can lead to account bans.
- **ALWAYS favor downloading a single article**: First list the course articles using `course -i <course_ID>` or `article -c <course_EnID>`, find the specific article ID, and use `python scripts/run_dedao.py dl <course_ID_or_EnID> <article_ID>`.
- **DEFAULT FORMAT**: Whenever you download content using `dl` or `dlo`, default to using `-t 3` (Markdown) unless the user explicitly asks for MP3 or PDF. Markdown is safer, faster, and easier to read.
- When generating markdown for a whole course (if permitted by the user), consider using `-m` to consolidate files unless the user explicitly asks for individual files.
don't have the plugin yet? install it then click "run inline in claude" again.
restructured into six implexa components, made ID type handling explicit (integer vs. EnID), added decision points for scope approval and format defaults, documented rate limit handling, clarified helper script requirement, and added outcome signals for each common workflow.
this skill guides you through using the dedao-dl CLI tool to interact with Dedao app content. use it when the user wants to list purchased courses, ebooks, audiobooks, or download them in various formats (PDF, MP3, Markdown, EPUB). the skill covers authentication, content discovery, and safe download workflows. default to markdown format and single-article downloads unless explicitly told otherwise.
CLI tool: dedao-dl binary (installed via python scripts/install_dedao_dl.py). always run commands through the helper script python scripts/run_dedao.py instead of the raw executable.
Authentication: user must be logged in to Dedao. login options are QR code (login -q) or cookie string (login -c "<cookie>"). store auth state locally in the dedao-dl config directory.
System dependencies:
wkhtmltopdf installed and in PATHffmpeg installed and in PATHexternal context: the user's Dedao account, login credentials, and purchased content library (courses, ebooks, audiobooks).
environment assumptions: script execution environment has python 3.7+, bash shell, network access to Dedao servers, and write permissions to the output directory.
verify installation: run python scripts/install_dedao_dl.py. if the binary already exists, skip to step 2. input: none. output: dedao-dl binary available in PATH or scripts/ directory.
check authentication status: run python scripts/run_dedao.py who. input: none. output: currently logged-in username, or error if not authenticated.
login if needed: if step 2 shows no user, run either python scripts/run_dedao.py login -q (scan QR code) or python scripts/run_dedao.py login -c "<cookie_string>" (paste cookie). input: QR code scan or cookie string. output: authentication confirmation message.
identify content type: determine whether user wants courses, ebooks, audiobooks, or other content. input: user request. output: content type category (course/ebook/audiobook/ace/topic/cat).
list content in that category: run the corresponding list command: python scripts/run_dedao.py course (purchased courses), python scripts/run_dedao.py free (free courses), python scripts/run_dedao.py ebook (ebooks), python scripts/run_dedao.py odob (audiobooks), python scripts/run_dedao.py ace (jinnang), python scripts/run_dedao.py topic (topics), or python scripts/run_dedao.py cat (all categories). input: none. output: list of items with IDs (integer ID for purchased courses, EnID string for free courses).
extract target ID: from the list output, locate the specific item ID the user wants. note: free courses return EnID strings (not integers); purchased courses return integer IDs. input: list output from step 5. output: single ID value (integer or EnID string).
list sub-items (courses only): if the target is a course and the user wants a specific article, run python scripts/run_dedao.py course -i <course_ID> (for purchased) or python scripts/run_dedao.py article -c <course_EnID> (for free). input: course ID or EnID. output: list of articles with article IDs.
extract article ID (if applicable): from step 7 output, locate the specific article ID. input: article list from step 7. output: single article ID.
determine download format and scope: ask or infer whether the user wants:
-t 1), PDF (-t 2), or Markdown (-t 3, agent default)-m), include comments (-c), add index prefix (-o)
input: user preference or agent inference. output: format flag and scope (single vs. full).execute download command: run the appropriate command based on content type and scope:
python scripts/run_dedao.py dl <course_ID_or_EnID> <article_ID> -t <format>python scripts/run_dedao.py dl <course_ID_or_EnID> -t <format> [options]python scripts/run_dedao.py dle <ebook_ID> -t <format>python scripts/run_dedao.py dlo <audiobook_ID> -t <format>
input: ID, article ID (if applicable), format flag, optional arguments. output: downloaded files in current working directory (or specified output path).handle rate limits and errors: if download fails with "496 NoCertificate" or similar rate limit error, wait 5-10 seconds and retry. if auth token expires mid-download, re-run login and retry. input: error message. output: successful retry or user notification of persistent failure.
verify output: check that files were created in the output directory with expected names and non-zero size. input: file system. output: confirmation of file existence and size.
if user is not logged in (step 2 returns no user): execute login in step 3. if login fails due to invalid credentials, prompt user to verify account or cookie string.
if user wants a single article vs. full course (step 9): if user says "download the course", confirm they understand it may contain hundreds of articles and take hours. if no explicit permission, default to single-article workflow (steps 7-8). never download a full course without explicit user permission.
if content type is a free course vs. purchased course (step 4-5): free courses return EnID strings; use article -c <EnID> to list articles. purchased courses return integer IDs; use course -i <ID> to list articles. do not mix ID types across commands.
if user wants markdown vs. PDF vs. MP3 (step 9): default to markdown (-t 3) unless user explicitly requests otherwise. if user requests PDF, warn them about rate limit risks and suggest adding sleep intervals if scripting bulk downloads. if user requests MP3 but ffmpeg is missing, alert them to install it first.
if ebook notes are requested (content type = ebook): offer either viewing notes inline (python scripts/run_dedao.py ebook notes -i <ebook_ID>) or exporting as markdown (python scripts/run_dedao.py dle <ebook_ID> -t 4).
if a course markdown download is approved and format is markdown (steps 9-10): consider suggesting -m (merge into single file) and -o (add index prefix) unless user explicitly asks for individual files.
if a download hangs or times out (step 11): wait 10 seconds, then retry. if it fails twice, report timeout to user and suggest they try again later or use a smaller scope (single article instead of full course).
single article download (most common): files appear in current working directory named <article_title>.<format> or similar. for markdown, typically <article_id>.md. for PDF, <article_id>.pdf. for MP3, <article_id>.mp3. file size must be > 0 bytes.
full course download (markdown with -m option): single merged file named something like <course_title>.md containing all articles concatenated with article titles as headers. alternative without -m: multiple files in a subdirectory, one per article, named 001_<article_title>.md, 002_<article_title>.md, etc. (if -o prefix was used).
ebook download: files named <ebook_id>.<format> (html, pdf, epub, or md for notes).
audiobook download: files named <audiobook_id>.<format> (mp3 or md for text).
authentication check (who command): output shows username and login timestamp.
list commands: output shows items in table format with ID column, title column, and metadata. free courses show EnID strings; purchased content shows integer IDs.
error conditions: if a command fails, stderr contains error code and message. common codes: "NoCertificate" (rate limited), "Unauthorized" (auth expired), "NotFound" (invalid ID). all output (stdout and stderr) cleaned by the helper script and readable without redirection.