How sebdelsol/sfvip-all works
Project type and purpose
• This is a Python-based Windows desktop application (“Sfvip All”) that wraps and extends an existing third-party app (Sfvip Player).
• It consists of two cooperating runtime processes: a GUI/main process and an embedded HTTP proxy (mitmproxy) that intercepts and patches Sfvip Player network calls.
• It also includes a companion CLI tool (user_proxy_cmd) for managing system-wide proxy settings in the Sfvip Player database.
File structure
• Top-level folders:
• dev/ → build, test, publish, translate scripts (PyInstaller, Nuitka, NSIS workflows)
• src/ → runtime code under three domains: mitm (proxy logic), sfvip (business/UI logic), winapi (Windows API helpers)
• shared/ → cross-domain utilities (versioning, job runner, caching, updates)
• resources/→ static templates, readme assets
• translations/ → localization JSON + Python bindings
• user_proxy_cmd/ → separate small CLI wrapper for global proxy management
• Configuration build scripts: build_config.py, requirements.txt, requirements.dev.txt
• Deployment artifacts: build/* (changelog, update manifests)
README for additional insights
• Describes features: “All” category injection, MPV and Sfvip auto-update, EPG support, caching.
• Runtime: two processes write logs side-by-side (main & mitmproxy).
• Build toolchain: Rust + Python envs, dev.create, dev.build, dev.publish, dev.upgrade, dev.scan, dev.translate.
• Packaging: PyInstaller or Nuitka → NSIS installer
Main components
a. Frontend/UI layer
• src/sfvip/ui/… : window management, widgets, splash, progress bar
• MPV integration via libmpv_dll
b. Business logic layer
• src/sfvip/*.py: account management, updates, caching, exceptions, scheduler
• shared/: config loader, update logic, job runner, md5, version
c. MitM proxy layer
• src/mitm/: custom addon for mitmproxy, cache cleaner, EPG server handler, proxy rules
d. External applications & services
• Third-party Sfvip Player executable
• MPV player binary
• External EPG data source (HTTP feed)
• GitHub API & DeepL API (build-time used by dev.publish, dev.translate)
e. Local storage
• Cache files, logs, config files under %LocalAppData% and application folder
f. Build and packaging pipeline (optional overlay)
• dev/ scripts → virtual envs → PyInstaller/Nuitka → NSIS → installer
Relationships and interactions
• Main App UI launches and manages both: the GUI event loop & embedded mitmproxy subprocess.
• Sfvip Player configured to use 127.0.0.1:port → all HTTP calls routed through mitmproxy.
• Mitmproxy intercepts JSON responses, applies “All” category injection, EPG merging.
• Main App caches categories & EPG data on disk for faster access.
• When user clicks Play, main app spawns MPV via libmpv_dll.
• Update logic: main app or dev.publish interacts with GitHub/DeepL to fetch new versions/localizations.
• user_proxy_cmd tool modifies Windows registry or Sfvip Player DB to set/remove proxy for all users.
Architectural patterns and design principles
• Layered architecture: UI → business logic → proxy → external services
• Process isolation: separate GUI and network-patching proxies
• Plugin/Add-On model: mitmproxy addons for extensibility
• Shared utilities to avoid duplication (shared/)
• Build pipeline as code (dev/ directory)
Diagramming recommendations
• Use clear labels for each component (e.g., “Main App Process”, “MitM Proxy”, “Sfvip Player”)
• App → Proxy → Internet
• Proxy → App (patched responses)
• App → MPV (playback)
• App ↔ Local FS (cache/log)
• Blue for internal components (src/, shared/)
• Green for external binaries/services (Sfvip Player, MPV, EPG feed)
• Orange for build pipeline (dev/)
• Ports (e.g., localhost:8080) and protocols (HTTP/HTTPS) if helpful