# yanruying/douyin-downloader architecture

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

- Interactive diagram: https://gitdiagram.com/yanruying/douyin-downloader
- Repository: https://github.com/yanruying/douyin-downloader

## Overview

YanRuYing’s Douyin homepage batch downloader is a PyQt6 desktop app. Users provide a profile link or choose saved users, fetch a profile’s posts or liked works, review/select parsed video, image, and live-photo tasks, then download them or export work metadata to Excel. Downloads support mix/date organization and skip-existing behavior. The graph follows the visible GUI/worker/API/parser flow and README capabilities; downloader, exporter, and some dialog internals were not sampled, so their detailed wiring is limited to documented or directly indicated links.

Main entry points: [`douyin_downloader/gui/worker.py`](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/worker.py) (Background worker), [`douyin_downloader/gui/main_window.py`](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/main_window.py) (Main window), [`douyin_downloader/core/api.py`](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/api.py) (Douyin API), [`douyin_downloader/core/downloader.py`](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/downloader.py) (Media downloader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Desktop interaction"]
  node_main["Main window<br/>[main_window.py]"]
  node_userlist["Saved users<br/>[dialog_userlist.py]"]
  node_worker["Background worker<br/>[worker.py]"]
  node_settings["Settings dialog<br/>[dialog_settings.py]"]
  node_cookie_dialog["Cookie dialog<br/>[dialog_cookie.py]"]
  node_browser_dialog["Login browser<br/>[dialog_browser.py]"]
end

subgraph group_collection["Profile and collection"]
  node_api["Douyin API<br/>[api.py]"]
  node_signing["Request signing<br/>[abogus.py]"]
end

subgraph group_media["Media processing"]
  node_parser["Aweme task parser<br/>[parser.py]"]
  node_downloader["Media downloader<br/>[downloader.py]"]
  node_files[("Downloaded files")]
  node_file_utils["Path and filename utilities<br/>[file_utils.py]"]
  node_exporter["Excel exporter<br/>[exporter.py]"]
  node_excel["Excel workbooks"]
end

subgraph group_preferences["Settings and outputs"]
  node_config["Configuration<br/>[config.py]"]
  node_config_file["INI configuration"]
end

node_user(("Desktop user"))
node_douyin(("Douyin service"))
node_browser(("Web browser"))

node_user -->|"enters links"| node_main
node_main -->|"opens saved users"| node_userlist
node_userlist -->|"loads/saves users"| node_config
node_main -->|"starts fetch/download"| node_worker
node_worker -->|"requests profile and works"| node_api
node_api -->|"signs requests"| node_signing
node_api -->|"sends API requests"| node_douyin
node_douyin -->|"returns profile and works"| node_api
node_worker -->|"builds media tasks"| node_parser
node_parser -->|"returns task lists"| node_main
node_main -->|"submits selected tasks"| node_worker
node_worker -->|"downloads tasks"| node_downloader
node_downloader -->|"builds paths"| node_file_utils
node_downloader -->|"writes media"| node_files
node_worker -->|"checks existing files"| node_file_utils
node_main -->|"requests Excel export"| node_worker
node_worker -->|"exports work data"| node_exporter
node_exporter -->|"writes workbook"| node_excel
node_main -->|"opens settings"| node_settings
node_settings -->|"reads and saves settings"| node_config
node_config -->|"reads/writes INI"| node_config_file
node_main -.->|"opens cookie setup"| node_cookie_dialog
node_cookie_dialog -.->|"starts login flow"| node_browser_dialog
node_browser_dialog -.->|"opens login browser"| node_browser
node_main -->|"checks cookie status"| node_worker
node_worker -->|"checks account status"| node_api

click node_main "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/main_window.py"
click node_userlist "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_userlist.py"
click node_worker "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/worker.py"
click node_settings "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_settings.py"
click node_cookie_dialog "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_cookie.py"
click node_browser_dialog "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_browser.py"
click node_config "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/utils/config.py"
click node_api "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/api.py"
click node_signing "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/abogus.py"
click node_parser "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/parser.py"
click node_downloader "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/downloader.py"
click node_file_utils "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/utils/file_utils.py"
click node_exporter "https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/exporter.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_main,node_userlist,node_worker,node_settings,node_cookie_dialog,node_browser_dialog,node_user,node_browser toneBlue
class node_api,node_signing toneAmber
class node_parser,node_downloader,node_files,node_file_utils,node_exporter,node_excel toneMint
class node_config,node_config_file toneRose
class node_douyin toneIndigo
```

## Components

### Desktop interaction

- [Main window](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/main_window.py): `douyin_downloader/gui/main_window.py`
- [Saved users](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_userlist.py): `douyin_downloader/gui/dialog_userlist.py`
- [Background worker](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/worker.py): `douyin_downloader/gui/worker.py`
- [Settings dialog](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_settings.py): `douyin_downloader/gui/dialog_settings.py`
- [Cookie dialog](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_cookie.py): `douyin_downloader/gui/dialog_cookie.py`
- [Login browser](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/gui/dialog_browser.py): `douyin_downloader/gui/dialog_browser.py`

### Profile and collection

- [Douyin API](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/api.py): `douyin_downloader/core/api.py`
- [Request signing](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/abogus.py): `douyin_downloader/core/abogus.py`

### Media processing

- [Aweme task parser](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/parser.py): `douyin_downloader/core/parser.py`
- [Media downloader](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/downloader.py): `douyin_downloader/core/downloader.py`
- **Downloaded files**
- [Path and filename utilities](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/utils/file_utils.py): `douyin_downloader/utils/file_utils.py`
- [Excel exporter](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/core/exporter.py): `douyin_downloader/core/exporter.py`
- **Excel workbooks**

### Settings and outputs

- [Configuration](https://github.com/yanruying/douyin-downloader/blob/main/douyin_downloader/utils/config.py): `douyin_downloader/utils/config.py`
- **INI configuration**

### Other components

- **Desktop user**
- **Douyin service**
- **Web browser**

## Connections

- Desktop user → Main window: enters links
- Main window → Saved users: opens saved users
- Saved users → Configuration: loads/saves users
- Main window → Background worker: starts fetch/download
- Background worker → Douyin API: requests profile and works
- Douyin API → Request signing: signs requests
- Douyin API → Douyin service: sends API requests
- Douyin service → Douyin API: returns profile and works
- Background worker → Aweme task parser: builds media tasks
- Aweme task parser → Main window: returns task lists
- Main window → Background worker: submits selected tasks
- Background worker → Media downloader: downloads tasks
- Media downloader → Path and filename utilities: builds paths
- Media downloader → Downloaded files: writes media
- Background worker → Path and filename utilities: checks existing files
- Main window → Background worker: requests Excel export
- Background worker → Excel exporter: exports work data
- Excel exporter → Excel workbooks: writes workbook
- Main window → Settings dialog: opens settings
- Settings dialog → Configuration: reads and saves settings
- Configuration → INI configuration: reads/writes INI
- Main window → Cookie dialog: opens cookie setup
- Cookie dialog → Login browser: starts login flow
- Login browser → Web browser: opens login browser
- Main window → Background worker: checks cookie status
- Background worker → Douyin API: checks account status
