# rookslog/mubi-downloader3 architecture

> Architecture diagram of the GitHub repository rookslog/mubi-downloader3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rookslog/mubi-downloader3
- Repository: https://github.com/rookslog/mubi-downloader3

## Overview

Mubi Downloader is an interactive command-line tool that finds a film, checks regional availability, uses browser-derived authentication to download and decrypt media, and processes subtitles and audio. The README also documents browser selection, WSL2 cookie access, and automatic track merging. The graph follows the CLI’s visible orchestration and the sampled module responsibilities; some internal download steps and the merger’s connection to downloads were not shown, so that link is marked unverified.

Main entry points: [`src/mubi_downloader/mubi_downloader.py`](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py) (Download and decrypt), [`src/mubi_downloader/__main__.py`](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/__main__.py) (CLI entry point), [`src/mubi_downloader/auth_manager.py`](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/auth_manager.py) (Cookie and auth manager), [`src/mubi_downloader/mergetomkv.py`](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mergetomkv.py) (MKV merger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["CLI entry point<br/>[__main__.py]"]
  node_search["Movie search<br/>[mubi_downloader.py]"]
  node_availability["Region check<br/>[__main__.py]"]
end

subgraph group_auth["Authentication and environment"]
  node_environment["Environment detection<br/>[environment.py]"]
  node_auth["Cookie and auth manager<br/>[auth_manager.py]"]
  node_browser_cookies[("Browser cookie stores")]
end

subgraph group_media["Download and media processing"]
  node_download["Download and decrypt<br/>[mubi_downloader.py]"]
  node_subtitles["Subtitle and audio processing<br/>[mubi_downloader.py]"]
  node_merger["MKV merger<br/>[mergetomkv.py]"]
  node_download_files["Downloaded media files"]
end

subgraph group_services["External services"]
  node_mubi_search["Film search service"]
  node_location_service["IP location service"]
  node_mubi_api["Mubi API"]
  node_drm_service["DRM license service"]
  node_streaming["Streaming media"]
end

node_user(("User"))

node_user -->|"runs"| node_cli
node_cli -->|"detects environment"| node_environment
node_cli -->|"initializes"| node_auth
node_auth -->|"gets cookie paths"| node_environment
node_auth -->|"reads cookies"| node_browser_cookies
node_cli -->|"searches film"| node_search
node_search -->|"queries"| node_mubi_search
node_search -->|"gets location"| node_location_service
node_cli -->|"checks region"| node_availability
node_cli -->|"starts download"| node_download
node_download -->|"prepares auth"| node_auth
node_download -->|"requests film access"| node_mubi_api
node_download -->|"fetches stream data"| node_streaming
node_download -->|"requests license"| node_drm_service
node_download -->|"writes media"| node_download_files
node_download -->|"processes tracks"| node_subtitles
node_download -.->|"may merge tracks"| node_merger
node_merger -->|"collects media"| node_download_files

click node_cli "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/__main__.py"
click node_search "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py"
click node_availability "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/__main__.py"
click node_environment "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/environment.py"
click node_auth "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/auth_manager.py"
click node_download "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py"
click node_subtitles "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py"
click node_merger "https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mergetomkv.py"

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_cli,node_search,node_availability,node_user toneBlue
class node_environment,node_auth,node_browser_cookies toneAmber
class node_download,node_subtitles,node_merger,node_download_files toneMint
class node_mubi_search,node_location_service,node_mubi_api,node_drm_service,node_streaming toneRose
```

## Components

### CLI workflow

- [CLI entry point](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/__main__.py): `src/mubi_downloader/__main__.py`
- [Movie search](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py): `src/mubi_downloader/mubi_downloader.py`
- [Region check](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/__main__.py): `src/mubi_downloader/__main__.py`

### Authentication and environment

- [Environment detection](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/environment.py): `src/mubi_downloader/environment.py`
- [Cookie and auth manager](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/auth_manager.py): `src/mubi_downloader/auth_manager.py`
- **Browser cookie stores**

### Download and media processing

- [Download and decrypt](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py): `src/mubi_downloader/mubi_downloader.py`
- [Subtitle and audio processing](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mubi_downloader.py): `src/mubi_downloader/mubi_downloader.py`
- [MKV merger](https://github.com/rookslog/mubi-downloader3/blob/main/src/mubi_downloader/mergetomkv.py): `src/mubi_downloader/mergetomkv.py`
- **Downloaded media files**

### External services

- **Film search service**
- **IP location service**
- **Mubi API**
- **DRM license service**
- **Streaming media**

### Other components

- **User**

## Connections

- User → CLI entry point: runs (evidence: `README.md`)
- CLI entry point → Environment detection: detects environment (evidence: `src/mubi_downloader/__main__.py`)
- CLI entry point → Cookie and auth manager: initializes (evidence: `src/mubi_downloader/__main__.py`)
- Cookie and auth manager → Environment detection: gets cookie paths (evidence: `src/mubi_downloader/auth_manager.py`)
- Cookie and auth manager → Browser cookie stores: reads cookies (evidence: `src/mubi_downloader/auth_manager.py`)
- CLI entry point → Movie search: searches film (evidence: `src/mubi_downloader/__main__.py`)
- Movie search → Film search service: queries (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Movie search → IP location service: gets location (evidence: `src/mubi_downloader/mubi_downloader.py`)
- CLI entry point → Region check: checks region (evidence: `src/mubi_downloader/__main__.py`)
- CLI entry point → Download and decrypt: starts download (evidence: `src/mubi_downloader/__main__.py`)
- Download and decrypt → Cookie and auth manager: prepares auth (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Download and decrypt → Mubi API: requests film access (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Download and decrypt → Streaming media: fetches stream data (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Download and decrypt → DRM license service: requests license (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Download and decrypt → Downloaded media files: writes media (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Download and decrypt → Subtitle and audio processing: processes tracks (evidence: `src/mubi_downloader/mubi_downloader.py`)
- Download and decrypt → MKV merger: may merge tracks (evidence: `README.md`)
- MKV merger → Downloaded media files: collects media (evidence: `src/mubi_downloader/mergetomkv.py`)
