# Live Recorder Live Recorder is a multi-platform live recording system built with: - Backend: `.NET 8 Web API + EF Core + SQLite` - Frontend: `Vue 3 + TypeScript + Element Plus` The current production-ready adapter is `DouyinLivePlatformAdapter`. The architecture keeps platform-specific logic isolated so Bilibili, Huya, Douyu, and Kuaishou can be added without changing application services. ## Architecture ```text . ├─ src │ ├─ LiveRecorder.Domain │ │ ├─ Entities │ │ └─ Enums │ ├─ LiveRecorder.Application │ │ ├─ Abstractions │ │ ├─ Common │ │ ├─ Models │ │ └─ Services │ ├─ LiveRecorder.Infrastructure │ │ ├─ Persistence │ │ ├─ Platforms │ │ │ ├─ Douyin │ │ │ ├─ Bilibili │ │ │ └─ Huya │ │ └─ Services │ └─ LiveRecorder.WebApi │ ├─ Controllers │ └─ Middleware └─ frontend └─ src ├─ api ├─ components ├─ router ├─ stores └─ views ``` ## Core design ### Domain - `LiveRoom`: platform, room id, source URL, title, anchor, cover, availability status - `RecordTask`: recording state, quality, output format, ffmpeg process id, output path - `RecordResult`: final file or segment directory, file size, duration, final status - `SystemLogEntry`: persistent system log - `AppSetting`: runtime settings store - `UserAccount`, `UserSession`: lightweight token-based sign-in ### Application - `ILivePlatformAdapter` - `ParseRoomAsync` - `GetLiveStatusAsync` - `GetStreamUrlAsync` - `ILivePlatformAdapterFactory` - `LiveRoomService` - `RecordService` - `SystemSettingsService` - `SystemLogService` - `AuthService` ### Infrastructure - `DouyinHttpClient` - wraps User-Agent, Referer, Cookie, and `ttwid` handling - `DouyinLivePlatformAdapter` - share-link resolution, room id extraction, status check, stream selection - `FfmpegService` - single file mode, segmented mode, reconnect arguments, recording templates - `LiveRoomPollingBackgroundService` - background polling scheduler for live detection and auto-start recording - `LiveRecorderDbContext` ### Web API - `AuthController` - `LiveRoomsController` - `RecordTasksController` - `LogsController` - `SettingsController` - `ApiTokenAuthenticationMiddleware` - `ExceptionHandlingMiddleware` ## Implemented features ### Douyin adapter - resolve share links and redirects - extract real `roomId` - call `https://live.douyin.com/webcast/room/web/enter/` - preload `ttwid` when needed - parse both: - `live_core_sdk_data.pull_data.stream_data` - `flv_pull_url / hls_pull_url_map` - select the highest quality by default or respect configured quality ### Background polling scheduler - configurable polling interval - configurable enable/disable switch - configurable auto-start switch - updates room status in background - auto-creates a recording task when a room is live and no task is running - also works as a recovery layer when ffmpeg exits unexpectedly while the room is still live ### Recording enhancements - save format setting: `MP4` or `TS` - save mode setting: - `SingleFile` - `Segmented` - recording template setting: - `StreamCopy` - `BalancedMp4` - `ArchiveTs` - reconnect tuning: - enable/disable reconnect - max reconnect delay - read/write timeout ### Frontend - login page - live room management - recording task list - recording task detail - log viewer - system settings - route lazy loading - vendor chunk splitting in Vite ## Settings exposed in UI - ffmpeg path - output root - default quality - live save format - save mode - recording template - segment duration - reconnect switch and reconnect delay - read/write timeout - background polling switch - auto-start-on-live switch - polling interval - Douyin User-Agent / Referer / Cookie ## Run ### Backend ```powershell dotnet restore LiveRecorder.sln dotnet build LiveRecorder.sln --no-restore -m:1 dotnet run --project src/LiveRecorder.WebApi/LiveRecorder.WebApi.csproj --urls http://localhost:5000 ``` Default account: - username: `admin` - password: `Admin@123` Swagger: - [http://localhost:5000/swagger](http://localhost:5000/swagger) ### Frontend ```powershell cd frontend npm install npm run dev ``` Frontend dev server: - [http://localhost:5173](http://localhost:5173) ## Verified locally - `dotnet build LiveRecorder.sln --no-restore -m:1` - `npm run build` ## Next steps 1. Implement full adapters for Bilibili, Huya, Douyu, and Kuaishou. 2. Add per-room recording preferences instead of relying only on global defaults. 3. Add full-text log search and time-range filters. 4. Replace lightweight token sessions with JWT or external SSO if needed.