mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 03:26:37 +08:00
0f30c34463
Backend
- service/ffprobe.go: thin ffprobe wrapper, parses duration / resolution /
codecs into a typed ProbeResult. 30s per-file timeout.
- service/tmdb.go: minimal TMDb provider (search/movie). Disabled when no
api key; supports tmdb_api_proxy / tmdb_image_proxy overrides for users
behind a firewall.
- service/scraper.go: filename cleaner (handles bracketed tags, scene
noise tokens, year extraction), per-row + per-library enrichment with a
4 RPS throttle and WS hub progress events. Unit-tested.
- service/scanner.go: now invokes ffprobe per file and kicks the TMDb
scraper in the background once a library scan finishes.
- service/transcoder.go: per-media ffmpeg HLS job manager; outputs
index.m3u8 + seg_NNNNN.ts under cache/hls/<id>; cancels jobs on
shutdown; publishes 'transcode' WS events.
- service/stream.go: serves HLS playlist (with 30s wait-for-ready) and
.ts segments with path-traversal protection. Adds Probe() helper used
by the admin 'reprobe' button.
- service/image_proxy.go: cached, host-allow-listed reverse proxy for
TMDb / Bangumi / Douban / Fanart / TheTVDB images so the SPA never
hits a CORS or GFW issue.
- service/playback.go: history upsert, favourites toggle, playlist CRUD
+ ordered items. RecentHistory joins with model.Media in one extra
query so the home page can render a 'Continue Watching' row.
- handler/streaming.go + handler/playback.go: REST endpoints for HLS,
image proxy, scrape (one + library), reprobe, history, favourites,
playlists.
- handler/handler.go: registers /api/hls/:id/{index.m3u8,:seg}, /api/img,
/api/history, /api/favourites/:id, /api/playlists/* with proper
auth/admin guards.
Frontend
- api/client.ts: imageURL() helper; hlsURL() endpoint; reuses the JWT in
a query parameter for <video src> and <img src>.
- api/playback.ts: typed helpers for history, favourites, playlists.
- components/MediaCard.tsx: optional 'progress' prop renders a thin
bottom progress bar, used by the new Continue Watching row.
- pages/HomePage.tsx: two rows (Continue Watching + Recently Added);
falls back to the empty-state hint when both are empty.
- pages/PlayerPage.tsx: hls.js (lazy-imported) with auto-fallback to
direct play; ?mode=hls|direct query toggle; resume position written
every 10s while playing.
- pages/MediaDetailPage.tsx: heart toggle + admin 'rescrape' / 'reprobe'
buttons + dedicated 'HLS 转码播放' CTA.
- pages/FavouritesPage.tsx, PlaylistsPage.tsx, PlaylistDetailPage.tsx:
new screens.
- components/Layout.tsx + App.tsx: sidebar links for Favourites and
Playlists; routes are now lazily code-split via React.lazy + Suspense
so the initial bundle stays at ~243 KB / 82 KB gzipped (hls.js is
fetched only on first HLS playback).
Verified: go build, go vet, go test (incl. CleanQuery cases) all pass;
frontend tsc -b && vite build emits 9 route chunks plus a deferred hls
chunk.
145 lines
5.4 KiB
Markdown
145 lines
5.4 KiB
Markdown
<h1 align="center">🎬 MediaStationGo</h1>
|
|
<p align="center">A Go rewrite of <a href="https://github.com/ShukeBta/MediaStation">MediaStation</a> — your private home media center.</p>
|
|
|
|
<p align="center">
|
|
<img src="https://img.shields.io/badge/Go-1.25-00ADD8?style=flat-square&logo=go" alt="Go">
|
|
<img src="https://img.shields.io/badge/React-18-61DAFB?style=flat-square&logo=react" alt="React">
|
|
<img src="https://img.shields.io/badge/TypeScript-5-3178C6?style=flat-square&logo=typescript" alt="TypeScript">
|
|
<img src="https://img.shields.io/badge/SQLite-WAL-003B57?style=flat-square&logo=sqlite" alt="SQLite">
|
|
<img src="https://img.shields.io/badge/Docker-Alpine_3.19-2496ED?style=flat-square&logo=docker" alt="Docker">
|
|
<img src="https://img.shields.io/badge/License-GPL--3.0-blue?style=flat-square" alt="License">
|
|
</p>
|
|
|
|
---
|
|
|
|
## Why a rewrite?
|
|
|
|
The original MediaStation is a Python/FastAPI + Vue project. **MediaStationGo**
|
|
is a from-scratch reimplementation that adopts the lighter, single-binary
|
|
deployment model used by [`cropflre/nowen-video`](https://github.com/cropflre/nowen-video):
|
|
|
|
- **Backend**: Go 1.25 + Gin + GORM + SQLite (WAL).
|
|
- **Frontend**: React 18 + Vite + Tailwind + Zustand.
|
|
- **Distribution**: one ~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) while making
|
|
deployment painless on NAS hardware.
|
|
|
|
---
|
|
|
|
## Features (current scaffold)
|
|
|
|
- ✅ JWT authentication with admin/user roles
|
|
- ✅ First-run admin seeding (`admin / admin123`)
|
|
- ✅ Library CRUD + recursive filesystem scan
|
|
- ✅ ffprobe metadata extraction (duration / resolution / codecs)
|
|
- ✅ TMDb scraper with image proxy (poster / backdrop / overview / rating)
|
|
- ✅ Direct-play streaming with HTTP `Range` support
|
|
- ✅ HLS on-demand transcoding (single ffmpeg job per media)
|
|
- ✅ Playback history (resume) + Continue Watching row
|
|
- ✅ Favourites + Playlists (CRUD + ordered items)
|
|
- ✅ Real-time scan / scrape / transcode progress via WebSocket
|
|
- ✅ React SPA with code-splitting: Login / Home / Library / Search /
|
|
Favourites / Playlists / Media detail / Player (HLS + direct) / Admin
|
|
- ✅ Single-binary build, multi-arch Docker image, GitHub Actions CI
|
|
|
|
### Roadmap
|
|
|
|
| Area | Status |
|
|
|------|--------|
|
|
| Bangumi / Douban / Fanart scraper providers | ⏳ |
|
|
| Hardware-accelerated transcoding (NVENC / QSV / VAAPI) | ⏳ |
|
|
| qBittorrent / Transmission / RSS automation | ⏳ |
|
|
| Subtitles (extract / search / sync) | ⏳ |
|
|
| Emby/Jellyfin compatibility layer | ⏳ |
|
|
| DLNA / Chromecast | ⏳ |
|
|
| AI metadata enhancement & smart search | ⏳ |
|
|
|
|
---
|
|
|
|
## 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 <http://localhost:8080> 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_`.
|
|
|
|
The most common 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_APP_CORS_ORIGINS` | *(empty)* | Allow-list, JSON array |
|
|
| `ADMIN_INITIAL_PASSWORD` | `admin123` | Bootstrap admin password |
|
|
|
|
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/media/scan/stream/ws)
|
|
│ ├── middleware/ Gin middleware (CORS / JWT / admin)
|
|
│ └── handler/ HTTP route definitions
|
|
├── web/ React 18 + Vite SPA
|
|
│ ├── src/api/ axios helpers
|
|
│ ├── src/components/ Layout, MediaCard, RequireAuth, …
|
|
│ ├── src/pages/ Home / Library / Search / Player / Admin
|
|
│ ├── 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).
|