# mapleshaw/yt-dlp-downloader-skill architecture

> Architecture diagram of the GitHub repository mapleshaw/yt-dlp-downloader-skill, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mapleshaw/yt-dlp-downloader-skill
- Repository: https://github.com/mapleshaw/yt-dlp-downloader-skill

## Overview

#### Purpose and Invocation

This repository is a Cursor Agent Skill that translates natural-language download requests into `yt-dlp` operations. It is not a standalone application or service; Cursor loads the skill definition and may invoke its shell helper.

Primary entry points:
- `SKILL.md` — agent-facing operating instructions, request interpretation, and command guidance.
- `scripts/download.sh` — executable download helper.
- `README.md` — installation and user-facing usage contract.

#### Skill Runtime Boundary

Cursor is the orchestration runtime. A user asks Cursor to download video, audio, subtitles, or a target quality; Cursor follows `SKILL.md` to select arguments and execute the local helper or `yt-dlp` command.

The repository itself does not implement media extraction or site support. Those responsibilities are delegated to installed command-line dependencies:
- `yt-dlp` handles URL extraction, site-specific access, downloads, format selection, subtitles, and resume behavior.
- `ffmpeg` is required by `yt-dlp` for audio extraction/conversion.

Relevant paths:
- `SKILL.md`
- `scripts/download.sh`

#### Request-to-Command Translation

The central control flow is:

1. User supplies a media URL and optional intent (video, MP3/audio, subtitles, 720p/1080p/best).
2. Cursor interprets the request using `SKILL.md`.
3. Cursor constructs or delegates to `scripts/download.sh`.
4. The helper invokes `yt-dlp` with the selected download options.
5. Downloaded artifacts are written to the local download destination.

This places intent parsing in the Cursor agent layer, while format and network behavior remain in `yt-dlp`.

#### Download Execution Component

`scripts/download.sh` is the operational boundary between agent instructions and the host shell. It provides a stable invocation surface for media download actions and should own shell-level concerns such as argument forwarding, destination selection, and command execution.

Path:
- `scripts/download.sh`

The host must have executable shell support plus installed `yt-dlp`; failures from remote sites, authentication, or media conversion surface through this command boundary.

#### Access and Authentication Handling

The intended mitigation for YouTube HTTP 403 responses is browser-cookie extraction via `yt-dlp` (for example, `--cookies-from-browser chrome`). This crosses an important local-security boundary: `yt-dlp` accesses browser-managed authentication cookies on the user’s machine rather than storing credentials in this repository.

Paths defining this behavior:
- `SKILL.md`
- `README.md`

No credential store, API backend, proxy service, or account-management subsystem is present.

#### External Service and Media Boundaries

Input URLs can target YouTube, Bilibili, Twitter/X, TikTok, Vimeo, Twitch, and other sources supported upstream by `yt-dlp`. Site extraction logic is external and changes with the installed `yt-dlp` version, not this repository.

Output media is local filesystem content. Audio extraction introduces an additional processing stage through `ffmpeg`; subtitle acquisition remains a `yt-dlp` responsibility.

#### Installation and Distribution

The skill is distributed as a small directory intended for Cursor’s skills location (`~/.cursor/skills/yt-dlp-downloader`). Manual installation requires preserving the expected layout so the agent instructions can locate the helper.

Repository layout anchors:
- `SKILL.md`
- `scripts/download.sh`
- `scripts/`

Main entry points: [`SKILL.md`](https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/SKILL.md) (Skill instructions), [`scripts/download.sh`](https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/scripts/download.sh) (Download helper), [`README.md`](https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/README.md) (Usage contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cursor["Cursor Runtime"]
  node_user_request["Download request<br/>user intent"]
  node_cursor_agent{{"Cursor Agent<br/>orchestrator"}}
end

subgraph group_skill["Skill Package"]
  node_skill_instructions["Skill instructions<br/>agent guidance<br/>[SKILL.md]"]
  node_download_helper["Download helper<br/>shell entry point<br/>[download.sh]"]
  node_readme["Usage contract<br/>documentation<br/>[README.md]"]
  node_skill_directory["Cursor skills location<br/>installation target"]
end

subgraph group_external["Host &amp; Upstream"]
  node_host_shell{{"Host shell<br/>execution runtime"}}
  node_yt_dlp["yt-dlp<br/>CLI dependency"]
  node_browser_cookies[("Browser cookies<br/>local credentials")]
  node_media_sites(("Media sites<br/>remote sources"))
  node_ffmpeg["ffmpeg<br/>media dependency"]
end

subgraph group_output["Local Output"]
  node_downloaded_media["Downloaded media<br/>local artifacts"]
end

node_user_request -->|"asks"| node_cursor_agent
node_cursor_agent -->|"follows"| node_skill_instructions
node_readme -.->|"documents installation"| node_skill_directory
node_skill_directory -->|"contains"| node_skill_instructions
node_skill_instructions -->|"selects invocation"| node_download_helper
node_cursor_agent -->|"executes"| node_download_helper
node_download_helper -->|"runs through"| node_host_shell
node_host_shell -->|"invokes"| node_yt_dlp
node_yt_dlp -->|"extracts from"| node_media_sites
node_browser_cookies -.->|"optional cookie extraction"| node_yt_dlp
node_ffmpeg -->|"audio conversion"| node_yt_dlp
node_yt_dlp -->|"writes"| node_downloaded_media
node_readme -.->|"documents 403 mitigation"| node_browser_cookies

click node_skill_instructions "https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/SKILL.md"
click node_download_helper "https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/scripts/download.sh"
click node_readme "https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_user_request,node_cursor_agent toneBlue
class node_skill_instructions,node_download_helper,node_readme,node_skill_directory toneAmber
class node_host_shell,node_yt_dlp,node_browser_cookies,node_media_sites,node_ffmpeg toneMint
class node_downloaded_media toneRose
```

## Components

### Cursor Runtime

Agent orchestration and request interpretation.

- **Download request**: user intent · URL plus video, audio, subtitle, or quality intent.
- **Cursor Agent**: orchestrator · Loads the skill and executes download commands.

### Skill Package

Installed under Cursor's skills directory.

- [Skill instructions](https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/SKILL.md): agent guidance · Maps natural-language requests to yt-dlp options. · `SKILL.md`
- [Download helper](https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/scripts/download.sh): shell entry point · Forwards selected arguments and runs the download command. · `scripts/download.sh`
- [Usage contract](https://github.com/mapleshaw/yt-dlp-downloader-skill/blob/master/README.md): documentation · Defines installation, usage, and cookie guidance. · `README.md`
- **Cursor skills location**: installation target · Expected skill directory layout for Cursor discovery.

### Host & Upstream

Dependencies and remote media sources.

- **Host shell**: execution runtime · Runs the executable helper locally.
- **yt-dlp**: CLI dependency · Performs extraction, format selection, downloads, subtitles, and resume.
- **Browser cookies**: local credentials · Optionally read by yt-dlp for authenticated access.
- **Media sites**: remote sources · YouTube and other sites supported by the installed yt-dlp version.
- **ffmpeg**: media dependency · Required for audio extraction and conversion.

### Local Output

- **Downloaded media**: local artifacts · Video, audio, and subtitle outputs at the selected destination.

## Connections

- Download request → Cursor Agent: asks
- Cursor Agent → Skill instructions: follows
- Usage contract → Cursor skills location: documents installation
- Cursor skills location → Skill instructions: contains
- Skill instructions → Download helper: selects invocation
- Cursor Agent → Download helper: executes
- Download helper → Host shell: runs through
- Host shell → yt-dlp: invokes
- yt-dlp → Media sites: extracts from
- Browser cookies → yt-dlp: optional cookie extraction
- ffmpeg → yt-dlp: audio conversion
- yt-dlp → Downloaded media: writes
- Usage contract → Browser cookies: documents 403 mitigation
