How ihmily/douyinliverecorder works
Project Type and Purpose
• This project is a multi-platform live streaming recorder that uses FFmpeg under the hood to capture and record live streams from various platforms (e.g., Douyin, TikTok, TwitchTV, etc.).
• Its purpose is to continuously monitor live-streaming URLs (configured through files like URL_config.ini) and record them while also supporting additional features like live status push notifications.
File Structure
• At the top level you have configuration files (e.g., “config/config.ini”, “config/URL_config.ini”), build and container orchestration files (Dockerfile, docker-compose.yaml, .dockerignore), and various deployment scripts (StopRecording.vbs, ffmpeg_install.py).
• Multiple Python scripts are present (e.g., main.py, demo.py, msg_push.py, i18n.py) along with dependency management files (requirements.txt, pyproject.toml, poetry.toml, setup.py).
• The “streamget” directory appears to be the core package containing modules that handle HTTP requests (async_http.py, sync_http.py), logging (logger.py), room info, stream grabbing, decryption (javascript folder with several JS files), as well as utility functions.
• Internationalization resources are stored under “i18n” for language translations.
• Docker and GitHub actions files indicate containerization, CI/CD, and deployment workflows.
Key Components and Their Captured Roles
• Configuration & Initialization: Config directory (URL_config.ini, config.ini) plus initializer.py or initializer-like calls ensure environment setup (nodejs check, proxy settings, etc.).
• Core Recording Engine:
• Main Controller: main.py, responsible for launching the overall recording process.
• Platform-specific Modules: In “streamget”, modules like spider.py (retrieves live stream data), room.py (fetches room info), stream.py (retrieves streaming address), and proxy.py which likely manages connection proxies.
• HTTP Clients: Both asynchronous and synchronous HTTP interactions are handled in the “http_clients” module.
• FFmpeg Integration: ffmpeg_install.py and the presence of ffmpeg.exe highlight the integration of the FFmpeg engine to perform actual streaming capture.
• Logging & Utilities: logger.py manages logging, and utils.py provides support functions.
• JavaScript Decryption: The “javascript” folder holds scripts to decrypt certain platform-specific streaming parameters (haixiu.js, liveme.js, etc.).
• Message Push Notifications: msg_push.py handles the live status notifications.
• Internationalization: The “i18n” folder, along with i18n.py, relates to providing multi-language support.
Relationships and Data Flow
• The main controller (main.py) coordinates the overall workflow:
– It reads configuration files from the config directory.
– It initializes the environment (using initializer.py) and sets up dependencies.
– It leverages the modules from the “streamget” package to fetch live video stream data, coordinate with appropriate HTTP clients, and then interface with FFmpeg to record streams.
• The recorded streams are saved into output directories (e.g., “downloads”) as indicated in the README.
• Status updates and potential notifications are pushed using the msg_push.py module.
• The system’s modular approach (separate modules for HTTP requests, logging, and platform-specific processing) signals a loosely coupled design.
Architectural Patterns & Technologies
• Modular Design: The project is partitioned into self-contained components (configuration, stream fetching, processing, notifications). This separation aids in maintenance and extensibility.
• Client-Server-Like Flow: While not a full microservice architecture, the separation of tasks (fetching with HTTP clients, processing with spiders, and controlling with main.py) can be conceptualized as “components talking” via well-defined interfaces.
• Use of Third-Party Tools: Integration with FFmpeg for processing and Docker for containerization are key points.
• Internationalization support and CI/CD pipelines (GitHub workflows) highlight additional concerns managed by the project.
Final Reminders for the Principal Software Engineer
• Be very detailed: It’s best to break down the application into as many logical components as possible based on the roles of each module.
• Configuration/Initialization → Orchestration (main.py) → Platform-specific data fetching → Stream processing (via FFmpeg) and logging/notification.
• Highlighting design principles like modularity and separation of concerns.
• You capture essential dependencies such as:
• Python version requirement (≥3.10)
• FFmpeg installation and integration
• Docker container orchestration (Dockerfile, docker-compose)
• External live streaming platforms (as inputs).