How mikumifa/bilitickerbuy works
Project type and purpose
• From the file tree and README we see this is an open‑source, Python‑based CLI application (“biliTickerBuy”) that automates B站会员购 (Bilibili membership purchase) flows. It bundles captcha‑solving models (ONNX), HTTP clients, task schedulers and notification utilities into a single distributable script/Docker image.
File structure
• Top‑level:
• main.py / const.py / main.spec – the application entry point, constants and PyInstaller spec.
• Dockerfile – containerized deployment.
• requirements.txt – Python dependencies (requests, onnxruntime, etc.).
• Directories by functional area:
• geetest/ – captcha‑solving engine and ONNX models.
• tab/ – modules for listing/querying available tickets (“go.py”, “problems.py”, “train.py”, “settings.py”).
• task/ – higher‑level automation tasks (e.g., purchase logic in buy.py).
• util/ – shared utilities (HTTP request wrapper, cookie manager, KV database, push‑notification clients, time service, dynamic import).
• CI/Release: .github/workflows, release-drafter, templates.
README for additional insights
• Confirms it’s a free, easy‑to‑use Bilibili membership‑purchase helper.
• Points at a user manual (not in repo) and describes how to raise issues/discussions.
1. CLI Entry Point (main.py)
2. Configuration Loader (util/config.py + const.py)
3. Task Manager (task/buy.py + dynamic importer util/dynimport.py)
4. Tab Manager (tab/go.py + related modules)
5. HTTP Client (util/BiliRequest.py)
6. Cookie Manager (util/CookieManager.py)
7. Captcha Solver (geetest/Validator.py + Amorter/Normal/Triple + ONNX models)
8. Local Storage (util/KVDatabase.py)
9. Notification Services (util/PushPlusUtil.py, ServerChanUtil.py)
10. External Services:
• Bilibili API endpoints
• Geetest CAPTCHA endpoint
• PushPlus / ServerChan notification gateways
11. Deployment Container (Docker) or Local Python Runtime
• The user invokes main.py → Configuration Loader initializes settings → Task Manager and/or Tab Manager instantiated.
• Task/Tab modules call HTTP Client, passing cookies from Cookie Manager.
• When a captcha challenge is encountered, HTTP Client routes to Captcha Solver, which loads ONNX models from geetest/model/*.onnx and returns a solved token.
• HTTP Client completes the Bilibili API request.
• Responses and state updates are written to Local Storage (KVDatabase).
• On success/failure, Notification Services push status to external channels.
c. Architectural patterns & design principles
• Layered structure: CLI → Orchestrator (tasks/tab) → Services (HTTP, Captcha, Storage) → External systems.
• Pluggable modules via dynamic import (util/dynimport.py).
• Separation of concerns between business logic (task/) and infrastructure (util/, geetest/).
• Containerization for repeatable deployment (Dockerfile + GitHub Actions).
d. Key technologies & frameworks
• Python 3.x
• requests or similar HTTP library (via util/BiliRequest)
• ONNX Runtime for model inference (geetest)
• PyInstaller spec (main.spec)
• Docker for container build/distribution
Diagramming conventions
• Rectangles (blue) for internal modules (main, task, tab).
• Rounded rectangles (green) for utility services (HTTP client, cookie, KV DB).
• Clouds (purple) for external endpoints (Bilibili API, Geetest, notification gateways).