How chenmozhijin/lddc works
Project type and purpose
• LDDC is a desktop application (cross-platform Windows/macOS/Linux) written in Python 3.10+.
• It provides precise, per-character lyrics download, matching, conversion, translation, and desktop–lyrics display via a PyQt GUI or CLI.
File structure and technical stack
• Top-level modules:
• LDDC/common: shared utilities, config, caching, logging, versioning
• LDDC/core: core engine
– algorithm.py (matching orchestrator)
– api/lyrics & api/translate (adapters to QQMusic, Kugou, NetEase, Lrclib, Bing/Google/OpenAI)
– auto_fetch, converter (LRC/SRT/ASS), decryptor (e.g. eapi, qmc1), parser (parser for various lyric formats), song_info
• LDDC/gui: PyQt-based UI
– ui (QtDesigner .ui files + generated code)
– view (controllers for each dialog/window)
– workers (background tasks for conversion, matching)
• Auxiliary files:
• build_helper.py, pyproject.toml (packaging)
• requirements*.txt (dependencies)
• .github/workflows (CI build/test)
• tests (unit/UI tests using pytest + PyQt test harness)
Information from README.md
• Emphasizes multi-threaded matching, per-character timing, multiple formats, translation, desktop-lyrics plugin compatibility.
• Lists external platforms (QQ音乐, 酷狗, 网易云, Lrclib) and translation APIs.
Main components
a. Frontends
• CLI interface (LDDC/__main__.py → common/args → core)
• GUI (PyQt layers: UI files → view controllers → service module → core)
b. Core Engine
• TaskManager / ThreadManager (multi-thread orchestration)
• Algorithm module (matching logic)
• API Adapters (lyrics fetch, translation fetch)
• Decryptors (encrypted local lyric formats)
• Parsers (input lyric‐format parsing)
• Converters (output format generation)
• SongInfo (metadata extraction)
c. Data layer
• Cache (common/data/cache.py)
• Local DB (common/data/local_song_lyrics_db.py)
• Config (common/data/config.py)
• File system (read/write lyric files, song tags)
d. External services
• Music platforms (QQMusic API, Kugou API, NetEase API, Lrclib)
• Translation APIs (Bing, Google, OpenAI)
e. Resources
• Qt resource file (res/resource.qrc)
• Images and translations (res/img, res/i18n)
Relationships and data flow
• User trigger → Frontend (CLI or GUI) → Service layer
• Service layer invokes Core Engine →
1. Fetch song metadata (SongInfo)
2. Request lyrics via API adapters (multi-threaded)
3. If encrypted, pass through decryptor → parser
4. Optionally request translation via translation adapters
5. Assemble per-character sync data → converter to desired format
6. Save to file system or local DB; optionally tag audio file
• Desktop-lyrics plugin subscribes to matching results via GUI service
• Cache layer avoids redundant external calls
Architectural patterns and design principles
• Layered architecture: Presentation (CLI/GUI) → Application service → Core engine → Data → External
• Adapter pattern for external APIs (lyrics & translation)
• Strategy pattern for parsing/converter modules
• Multi-threading concerns isolated in TaskManager/ThreadManager
• MVC-ish separation in GUI: .ui → view → service