π¬ MediaStationGo
A Go rewrite of MediaStation β your private home media center.
δΈζ
---
## Why a rewrite?
The original MediaStation is a Python/FastAPI + Vue project. **MediaStationGo** is a from-scratch reimplementation that adopts a lighter, single-binary deployment model:
- **Backend**: Go 1.25 + Gin + GORM + SQLite (WAL mode).
- **Frontend**: React 18 + Vite + Tailwind CSS + Zustand.
- **Distribution**: ~30 MB static binary (CGO disabled), or a multi-arch Alpine Docker image.
The goal is to keep the user-facing feature surface familiar (libraries, scanning, scraping, direct play/HLS, multi-user, downloads, RSS) while making deployment painless on NAS hardware.
---
## Features
### Authentication & Users
- β
JWT auth with admin/user roles
- β
First-run admin seeding (`admin / admin123`, override via `ADMIN_INITIAL_PASSWORD`)
- β
Profile page (email / avatar / change password)
- β
Admin user table with role promotion / demotion
- β
Audit log for sensitive actions (login, library CRUD, downloads, etc.)
### Library Management
- β
Library CRUD + recursive filesystem scan
- β
ffprobe metadata extraction (duration / resolution / codecs / container)
- β
Smart filename cleaning with year + season/episode parsing
- β
Multi-provider scrape chain by library type:
- movie β TMDb (with optional Fanart.tv high-res poster upgrade)
- tv β TheTVDB (fallback TMDb)
- anime β Bangumi (fallback TMDb)
- β
Image proxy with disk cache (TMDb / Bangumi / Douban / Fanart / TheTVDB)
- β
TV / anime libraries grouped by season with episode listing
- β
fsnotify-based filesystem watcher with 5 s coalescing debouncer
### Playback
- β
Direct-play streaming with HTTP `Range` support
- β
HLS on-demand transcoding (single ffmpeg job per media)
- β
External subtitle discovery (.srt / .vtt / .ass / .ssa) with on-the-fly WebVTT conversion
- β
Resume position written every 10 s + Continue Watching row on home
- β
Favourites (toggle) + ordered Playlists (CRUD)
### PT Site Management
- β
Site configuration CRUD
- β
6 PT site types: nexusphp / gazelle / unit3d / mteam / discuz / custom_rss
- β
3 auth methods: Cookie / API Key / Auth Header
- β
Site connection testing
- β
Cross-site torrent search
- β
Extended config via Extra JSON (User-Agent / RSS URL / timeout / priority / proxy / downloader)
### Automation
- β
qBittorrent download integration (add / list / delete via Web UI API)
- β
RSS subscriptions with regex filters, GUID dedup and 10-minute polling
- β
Automatic media file organization (move / copy / hardlink / symlink)
### Operations
- β
Real-time scan / scrape / transcode / download / subscription events over WebSocket
- β
Dashboard at `/stats` (CPU / memory / disk / library counts / Goroutines)
- β
Real-time tasks panel at `/tasks` (active ffmpeg jobs + qBittorrent torrents)
- β
NFO export (Kodi / Jellyfin compatibility) β single media or whole library
- β
Hardware-accel encoder profiles: Software / NVENC / Intel QSV / VAAPI
- β
Single-binary build, multi-arch Docker image, GitHub Actions CI + GHCR publish
### Discovery & AI
- β
TMDb Discover β trending + popular rails on homepage
- β
AI smart search (OpenAI-compatible) β natural-language queries β structured intent
- β
AI recommendations seeded from your watch history (`GET /api/ai/recommend`)
### Frontend
- β
React SPA with code-splitting: Login / Home / Library / Search / Favourites / Playlists /
Media detail / Player (HLS + direct + subtitles) / Profile / Downloads / Subscriptions /
Stats / Admin / Site Management / API Config
- β
Global toast notifications driven by the WebSocket hub
- β
Initial bundle ~250 KB / 83 KB gzipped (hls.js loaded only on first HLS playback)
### Roadmap
| Feature | Status |
|---------|--------|
| Bidirectional Jellyfin / Emby compatibility layer | β³ |
| DLNA / Chromecast | β³ |
| Online subtitle search providers | β³ |
| Multi-bitrate ABR transcode profiles | β³ |
---
## Quick Start
### Docker
```bash
git clone https://github.com/ShukeBta/MediaStationGo.git
cd MediaStationGo
# (optional) edit docker-compose.yml to mount your media root at /media
docker compose up -d
```
Open and log in with `admin / admin123`.
### Bare Metal
```bash
# requirements: Go 1.25+, Node 20+, ffmpeg
make build # produces bin/mediastation-go and web/dist
./bin/mediastation-go
```
### Local Development
```bash
make dev # backend on :8080, MEDIASTATION_APP_DEBUG=true
make dev-web # vite dev server on :3000, proxies /api -> :8080
```
---
## Configuration
Configuration is layered β defaults < `config.yaml` < `config/*.yaml` < environment variables prefixed with `MEDIASTATION_`.
### Most-Used Keys
| Key | Default | Purpose |
|-----|---------|---------|
| `MEDIASTATION_APP_PORT` | `8080` | HTTP listen port |
| `MEDIASTATION_APP_DATA_DIR` | `./data` | DB / cache / JWT secret root |
| `MEDIASTATION_APP_WEB_DIR` | `./web/dist` | SPA bundle to serve |
| `MEDIASTATION_DATABASE_DB_PATH` | `./data/mediastation.db` | SQLite file |
| `MEDIASTATION_SECRETS_JWT_SECRET` | *(auto)* | JWT signing key |
| `MEDIASTATION_SECRETS_TMDB_API_KEY` | *(empty)* | Enables movie scraping |
| `MEDIASTATION_SECRETS_BANGUMI_ACCESS_TOKEN` | *(empty)* | Optional, raises Bangumi rate limit |
| `MEDIASTATION_APP_CORS_ORIGINS` | *(empty)* | Allow-list, JSON array |
| `ADMIN_INITIAL_PASSWORD` | `admin123` | Bootstrap admin password |
### Runtime Settings (Admin β Settings)
These live in the `settings` table and can be edited from the admin UI:
| Key | Purpose |
|-----|---------|
| `qbittorrent.url` | qBittorrent Web UI base URL |
| `qbittorrent.username` | qBittorrent user |
| `qbittorrent.password` | qBittorrent password |
| `qbittorrent.savepath` | Optional default save path for new torrents |
After editing, hit **Downloads β Reload Config** (or `POST /api/downloads/reload`) so the qBittorrent client picks up the new credentials.
See [`config.example.yaml`](config.example.yaml) for the full surface.
---
## Project Layout
```
MediaStationGo/
βββ cmd/server/main.go Application entry point
βββ internal/
β βββ config/ Viper-based config loader
β βββ database/ GORM + SQLite (WAL) bootstrap
β βββ model/ GORM data models + AutoMigrate registry
β βββ repository/ Thin data-access layer
β βββ service/ Business logic
β β βββ auth.go login / register / JWT / seed admin
β β βββ media.go library + media CRUD
β β βββ scanner.go fs walker + ffprobe + scrape kick
β β βββ ffprobe.go ffprobe wrapper
β β βββ tmdb.go TMDb provider
β β βββ bangumi.go Bangumi provider
β β βββ scraper.go orchestrator + filename cleaner
β β βββ site.go PT site CRUD + connection test + cross-site search
β β βββ site_adapter.go 6 PT site type adapters
β β βββ stream.go direct play + HLS playlist / segment
β β βββ transcoder.go per-media ffmpeg HLS job manager
β β βββ subtitle.go external subtitle discovery + .vtt conversion
β β βββ image_proxy.go cached, allow-listed image proxy
β β βββ playback.go history / favourites / playlists
β β βββ watcher.go fsnotify debouncer
β β βββ qbittorrent.go qBittorrent v2 API client
β β βββ downloads.go download orchestrator + WS poller
β β βββ subscription.go RSS poller
β β βββ stats.go dashboard snapshot
β β βββ profile.go non-credential user mutations
β β βββ audit.go audit log writer
β β βββ organizer.go media file organizer
β β βββ ws_hub.go pub/sub broker for the WS
β β βββ walk.go / episode_parser.go helpers
β βββ middleware/ Gin middleware (CORS / JWT / admin)
β βββ handler/ HTTP route definitions (one file per concern)
βββ web/ React 18 + Vite SPA
β βββ src/api/ axios helpers (one per service)
β βββ src/components/ Layout, MediaCard, GlobalEvents, RequireAuth, APIConfigsPanel
β βββ src/hooks/ useWebSocket, β¦
β βββ src/pages/ Home / Library / Search / Player / Downloads / Admin / Sites
β βββ src/stores/ Zustand (auth)
β βββ src/types/ Domain types mirrored from Go
βββ Dockerfile Multi-stage, multi-arch build
βββ docker-compose.yml NAS-friendly deployment
βββ Makefile build / dev / docker / test
βββ config.example.yaml Full configuration template
βββ .github/workflows/ CI + GHCR publish
```
---
## License
Released under the [GNU GPL v3.0](LICENSE).