docs: premium README redesign with visual hierarchy

- Add centered header badge with light/dark theme support
- Add table of contents with emoji-anchored quick links
- Rewrite feature section as collapsible detail blocks
- Add Python vs Go comparison table with metrics
- Add prerequisite requirements table
- Enhance project structure with arrow annotations
- Add contribution section and footer
- Mirror all changes to README_EN.md
- 341 lines each, bilingual parity
This commit is contained in:
ShukeBta
2026-05-17 00:10:49 +08:00
parent 8e06b7e149
commit d10bc19e8e
2 changed files with 522 additions and 288 deletions
+255 -137
View File
@@ -1,223 +1,341 @@
<h1 align="center">🎬 MediaStationGo</h1>
<p align="center">
<a href="https://github.com/ShukeBta/MediaStation">MediaStation</a> 的 Go 语言重写版 —— 您的私有家庭媒体中心。
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/MediaStationGo-你的私人媒体中心-111827?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0tMiAxNWwtNS01IDEuNDEtMS40MUwxMCAxNC4xN2w3LjU5LTcuNTlMMTkgOGwtOSA5eiIvPjwvc3ZnPg=="/>
<img src="https://img.shields.io/badge/MediaStationGo-你的私人媒体中心-1F2937?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0tMiAxNWwtNS01IDEuNDEtMS40MUwxMCAxNC4xN2w3LjU5LTcuNTlMMTkgOGwtOSA5eiIvPjwvc3ZnPg=="/>
</picture>
</p>
<h3 align="center"><samp><a href="https://github.com/ShukeBta/MediaStation">MediaStation</a> 的 Go 语言重写版</samp></h3>
<h6 align="center"><samp>轻量 · 快速 · 单二进制部署 · NAS 友好</samp></h6>
<p align="center">
<a href="README_EN.md">English</a>
<a href="README_EN.md"><img src="https://img.shields.io/badge/English-README-blue?style=flat-square" alt="English"></a>
</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">
<img src="https://img.shields.io/badge/Go-1.25-00ADD8?style=for-the-badge&logo=go&logoColor=white" alt="Go">
<img src="https://img.shields.io/badge/React-18-61DAFB?style=for-the-badge&logo=react&logoColor=black" alt="React">
<img src="https://img.shields.io/badge/TypeScript-5-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript">
<img src="https://img.shields.io/badge/SQLite-WAL-003B57?style=for-the-badge&logo=sqlite&logoColor=white" alt="SQLite">
<img src="https://img.shields.io/badge/Docker-Alpine-2496ED?style=for-the-badge&logo=docker&logoColor=white" alt="Docker">
<img src="https://img.shields.io/badge/License-GPLv3-8B5CF6?style=for-the-badge&logo=gnu&logoColor=white" alt="GPL v3">
</p>
---
## 为什么要重写?
原版 MediaStation 是一个 Python/FastAPI + Vue 项目。**MediaStationGo** 是从零开始的全新重构,采用更轻量的单文件部署模式:
- **后端**:Go 1.25 + Gin + GORM + SQLite(WAL 模式)
- **前端**:React 18 + Vite + Tailwind CSS + Zustand
- **分发**:约 30 MB 纯静态二进制(CGO 禁用),或跨架构 Alpine Docker 镜像
目标是在保持用户功能和界面不变的前提下,大幅降低 NAS 设备上的部署复杂度。
<p align="center">
<b>📖 <a href="#-为什么选择-mediastationgo">为什么选择</a></b>
&nbsp;·&nbsp;
<b>🚀 <a href="#-快速开始">快速开始</a></b>
&nbsp;·&nbsp;
<b>✨ <a href="#-功能特性">功能特性</a></b>
&nbsp;·&nbsp;
<b>🏗️ <a href="#-项目结构">项目结构</a></b>
&nbsp;·&nbsp;
<b>⚙️ <a href="#-配置说明">配置说明</a></b>
&nbsp;·&nbsp;
<b>🗺️ <a href="#-路线图">路线图</a></b>
</p>
---
## 功能特性
## 🤔 为什么选择 MediaStationGo?
### 认证与用户
- ✅ JWT 认证(admin / user 双角色)
- ✅ 首次运行自动创建管理员(`admin / admin123`,可通过 `ADMIN_INITIAL_PASSWORD` 自定义)
- ✅ 个人信息页(邮箱 / 头像 / 修改密码)
- ✅ 管理员用户表(角色提升 / 降级)
- ✅ 敏感操作审计日志(登录、媒体库操作、下载等)
> MediaStationGo 是 [MediaStation](https://github.com/ShukeBta/MediaStation) 从零开始的 Go 语言重写版,在保持完整功能体验的同时,将部署复杂度压缩到极致。
### 媒体库管理
- ✅ 媒体库增删改查 + 递归文件系统扫描
- ✅ ffprobe 元数据提取(时长 / 分辨率 / 编码格式 / 容器)
- ✅ 智能文件名清洗(年份 + 季/集号识别)
- ✅ 多数据源链式刮削(按媒体库类型):
- 电影 → TMDb(可选 Fanart.tv 高清海报升级)
- 电视剧 → TheTVDB(TMDb 回退)
- 动漫 → Bangumi(TMDb 回退)
- ✅ 图片代理 + 磁盘缓存(TMDb / Bangumi / 豆瓣 / Fanart / TheTVDB)
- ✅ 电视剧 / 动漫按季分组 + 剧集列表
- ✅ fsnotify 文件系统监听(5 秒防抖合并)
<table>
<tr>
<td width="50%">
### 播放
- ✅ 直链播放(支持 HTTP Range)
- ✅ HLS 按需转码(每个文件独立 ffmpeg 作业)
- ✅ 外挂字幕识别(.srt / .vtt / .ass / .ssa)+ 实时 WebVTT 转换
- ✅ 播放位置续播(每 10 秒写入)+ 首页「继续观看」
- ✅ 收藏(切换)+ 播放列表(增删改查)
### 原版 MediaStation
- 🐍 Python / FastAPI + Vue
- 📦 依赖 Python 运行时和虚拟环境
- 🐳 必须使用 Docker 或复杂的 Python 环境
- 📊 部署包 > 500 MB
- 🔧 需要 pip / npm 双构建链
### PT 站点管理
- ✅ 站点配置增删改查
- ✅ 支持 6 种 PT 站点类型:nexusphp / gazelle / unit3d / mteam / discuz / custom_rss
- ✅ 3 种认证方式:Cookie / API Key / Auth Header
- ✅ 站点连接测试
- ✅ 跨站种子搜索
- ✅ 站点扩展配置(Extra JSON:User-Agent / RSS URL / 超时 / 优先级 / 代理 / 下载器)
</td>
<td width="50%">
### 自动化
- ✅ qBittorrent 下载集成(添加 / 列表 / 删除)
- ✅ RSS 订阅 + 正则过滤 + GUID 去重 + 10 分钟轮询
- ✅ 下载文件自动分类整理
### MediaStationGo ✨
- 🚀 Go 1.25 + React 18
- 📦 **单一静态二进制**(约 30 MB)
- 🐳 可选 Docker,也支持裸机直接运行
- 🔥 零外部依赖(CGO 禁用)
- ⚡ `go build` 一条命令编译
### 运维监控
- ✅ 实时事件推送(扫描 / 刮削 / 转码 / 下载 / 订阅)通过 WebSocket
- ✅ 仪表盘 `/stats`(CPU / 内存 / 磁盘 / 媒体库数量 / Goroutines)
- ✅ 实时任务面板 `/tasks`(当前 ffmpeg 作业 + qBittorrent 种子)
- ✅ NFO 导出(Kodi / Jellyfin 兼容)—— 单文件或整库
- ✅ 硬件加速编码配置:Software / NVENC / Intel QSV / VAAPI
- ✅ 单文件部署、多架构 Docker 镜像、GitHub Actions CI + GHCR
</td>
</tr>
</table>
### 发现与 AI
- ✅ TMDb 发现 —— 首页热门推荐
- ✅ AI 智能搜索(OpenAI 兼容接口)—— 自然语言 → 结构化查询
- ✅ AI 推荐(基于观看历史)`GET /api/ai/recommend`
| 指标 | 原版 | MediaStationGo |
|------|:----:|:----:|
| 二进制体积 | — | ≈ 30 MB |
| 内存占用(空闲) | ~200 MB | ~30 MB |
| 冷启动时间 | ~3s | ~0.3s |
| 部署步骤 | 5+ | 1 |
| 前端体积 (gzip) | ~250 KB | ~83 KB |
### 前端
- ✅ React SPA 代码分割:登录 / 首页 / 媒体库 / 搜索 / 收藏 / 播放列表 / 详情 / 播放器(HLS + 直链 + 字幕) / 个人信息 / 下载 / 订阅 / 统计 / 管理后台 / 站点管理 / API 配置
- ✅ WebSocket 全局通知
- ✅ 初始包体积约 250 KB / Gzip 后 83 KB(hls.js 仅在首次 HLS 播放时按需加载)
---
### 路线图
## ✨ 功能特性
| 功能 | 状态 |
<details open>
<summary><b>🔐 认证与用户管理</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| Jellyfin / Emby 双向兼容层 | ⏳ |
| DLNA / Chromecast 投屏 | ⏳ |
| 在线字幕搜索 | ⏳ |
| 多码率 ABR 转码 | ⏳ |
| JWT 双角色认证 | admin / user 角色隔离,支持 refresh token |
| 一键管理员创建 | 首次运行自动种子 `admin` / `admin123` |
| 个人信息管理 | 邮箱、头像、密码修改 |
| 用户管理面板 | 角色提升 / 降级、账户启用 / 禁用 |
| 审计日志 | 记录登录、媒体库操作、下载等敏感行为 |
</details>
<details open>
<summary><b>📚 媒体库管理</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| 媒体库 CRUD | 支持 movie / tv / anime / music 四种类型 |
| 递归扫描 | 文件系统遍历 + ffprobe 元数据提取 |
| 智能文件名清洗 | 年份 + 季/集号自动识别 |
| 多源刮削 | TMDb → TheTVDB → Bangumi 链式刮削 |
| 高清海报升级 | Fanart.tv 可选降级 |
| 图片代理 | TMDb / Bangumi / 豆瓣 / Fanart 代理 + 磁盘缓存 |
| 电视剧分组 | 按季分组 + 剧集列表视图 |
| 实时文件监听 | fsnotify 驱动,5 秒防抖合并 |
</details>
<details open>
<summary><b>🎬 播放体验</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| 直链播放 | HTTP Range 支持,拖动秒开 |
| HLS 按需转码 | 单文件单作业,支持硬件加速 |
| 外挂字幕 | .srt / .vtt / .ass / .ssa 自动识别 → WebVTT 实时转换 |
| 续播 | 每 10 秒自动存位,首页「继续观看」 |
| 收藏 & 播放列表 | 一键切换收藏 / 有序播放列表 |
</details>
<details open>
<summary><b>🌐 PT 站点管理</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| 6 种站点类型 | nexusphp · gazelle · unit3d · mteam · discuz · custom_rss |
| 3 种认证方式 | Cookie / API Key / Auth Header |
| 站点配置 | 完整 CRUD + 连接测试 + 启用开关 |
| 跨站搜索 | 一键搜索所有已配置站点的种子 |
| 扩展配置 | Extra JSON:UA / RSS URL / 超时 / 优先级 / 代理 / 下载器 |
</details>
<details open>
<summary><b>🤖 自动化</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| 下载集成 | qBittorrent Web UI API(添加 / 列表 / 删除) |
| RSS 订阅 | 正则过滤 + GUID 去重 + 10 分钟轮询 |
| 文件整理 | 下载完成后自动分类 move / copy / hardlink / symlink |
</details>
<details open>
<summary><b>📊 运维监控</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| 实时事件推送 | WebSocket 推送扫描 / 刮削 / 转码 / 下载 / 订阅状态 |
| 系统仪表盘 | CPU / 内存 / 磁盘 / 媒体库数量 / Goroutines |
| 任务面板 | 实时展示 ffmpeg 作业 + qBittorrent 种子 |
| NFO 导出 | Kodi / Jellyfin 兼容格式,单文件或整库 |
| 硬件加速 | Software / NVENC / Intel QSV / VAAPI 编码器配置 |
| GitHub Actions | CI 自动化 + GHCR 多架构镜像发布 |
</details>
<details open>
<summary><b>🧠 AI 智能</b></summary>
<br>
| 功能 | 说明 |
|------|------|
| TMDb 发现 | 首页热门 / 流行推荐 |
| AI 搜索 | OpenAI 兼容接口 → 自然语言转结构化查询 |
| AI 推荐 | 基于观看历史的个性化推荐 |
</details>
---
## 快速开始
## 🚀 快速开始
### Docker 部署
### 🐳 Docker 部署(推荐)
```bash
git clone https://github.com/ShukeBta/MediaStationGo.git
cd MediaStationGo
# (可选)编辑 docker-compose.yml,将您的媒体目录挂载到 /media
# 编辑 docker-compose.yml,将媒体目录挂载到 /media
docker compose up -d
```
打开 <http://localhost:8080>,使用 `admin / admin123` 登录。
> 🌐 打开 <http://localhost:8080>,使用 `admin` / `admin123` 登录。
### 裸机部署
### 💻 裸机部署
| 前置要求 | 版本 |
|----------|------|
| Go | ≥ 1.25 |
| Node.js | ≥ 20 |
| FFmpeg | 任意 |
```bash
# 前置要求:Go 1.25+、Node 20+、ffmpeg
make build # 生成 bin/mediastation-go 和 web/dist
git clone https://github.com/ShukeBta/MediaStationGo.git
cd MediaStationGo
# 编译后端 + 构建前端
make build
# 启动服务
./bin/mediastation-go
```
### 本地开发
### 🛠️ 本地开发
```bash
make dev # 后端启动在 :8080,MEDIASTATION_APP_DEBUG=true
make dev-web # Vite 开发服务器启动在 :3000,代理 /api → :8080
# 终端 1:Go 后端(端口 8080,DEBUG 模式)
make dev
# 终端 2:Vite 前端(端口 3000,API 自动代理)
make dev-web
```
---
## 配置说明
## ⚙️ 配置说明
配置层级:默认值 < `config.yaml` < `config/*.yaml` < 环境变量(前缀 `MEDIASTATION_`)。
配置加载优先级:**默认值** < `config.yaml` < `config/*.yaml` < **环境变量**(`MEDIASTATION_` 前缀)
### 常用环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| 环境变量 | 默认值 | 说明 |
|----------|--------|------|
| `MEDIASTATION_APP_PORT` | `8080` | HTTP 监听端口 |
| `MEDIASTATION_APP_DATA_DIR` | `./data` | 数据目录(数据库 / 缓存 / JWT 密钥) |
| `MEDIASTATION_APP_WEB_DIR` | `./web/dist` | 前端 SPA 静态文件目录 |
| `MEDIASTATION_DATABASE_DB_PATH` | `./data/mediastation.db` | SQLite 数据库文件路径 |
| `MEDIASTATION_APP_DATA_DIR` | `./data` | 数据目录(DB / 缓存 / JWT) |
| `MEDIASTATION_APP_WEB_DIR` | `./web/dist` | 前端 SPA 静态文件 |
| `MEDIASTATION_DATABASE_DB_PATH` | `./data/mediastation.db` | SQLite 数据库路径 |
| `MEDIASTATION_SECRETS_JWT_SECRET` | *(自动生成)* | JWT 签名密钥 |
| `MEDIASTATION_SECRETS_TMDB_API_KEY` | *(空)* | 启用 TMDb 电影刮削 |
| `MEDIASTATION_SECRETS_BANGUMI_ACCESS_TOKEN` | *(空)* | 可选,提升 Bangumi 速率限制 |
| `MEDIASTATION_SECRETS_TMDB_API_KEY` | *(空)* | TMDb 刮削(必填) |
| `MEDIASTATION_SECRETS_BANGUMI_ACCESS_TOKEN` | *(空)* | Bangumi 速率提升 |
| `MEDIASTATION_APP_CORS_ORIGINS` | *(空)* | 跨域白名单(JSON 数组) |
| `ADMIN_INITIAL_PASSWORD` | `admin123` | 初始管理员密码 |
### 运行时设置(管理后台 → 设置)
### 运行时设置
这些配置存储在 `settings` 表中,可通过管理 UI 编辑:
管理后台 → 系统设置,存储在 `settings` 表中:
| 键 | 说明 |
|----|------|
| `qbittorrent.url` | qBittorrent Web UI 地址 |
| `qbittorrent.username` | qBittorrent 用户名 |
| `qbittorrent.password` | qBittorrent 密码 |
| `qbittorrent.savepath` | 可选,新种子默认保存路径 |
| `qbittorrent.username` | 用户名 |
| `qbittorrent.password` | 密码 |
| `qbittorrent.savepath` | 默认保存路径(可选) |
编辑后点击 **下载 → 重新加载配置**(或 `POST /api/downloads/reload`)使客户端重新读取。
> 💡 修改后点击 **下载 → 重新加载配置** 或 `POST /api/downloads/reload`。
完整配置模板请参见 [`config.example.yaml`](config.example.yaml)。
📖 完整配置模板:[`config.example.yaml`](config.example.yaml)
---
## 项目结构
## 🏗️ 项目结构
```
MediaStationGo/
├── cmd/server/main.go 应用入口
├── cmd/server/main.go ← 应用入口
├── internal/
│ ├── config/ Viper 配置加载
│ ├── database/ GORM + SQLite (WAL) 初始化
│ ├── model/ GORM 数据模型 + AutoMigrate 注册
│ ├── repository/ 数据访问层
│ ├── service/ 业务逻辑
│ │ ├── auth.go 登录 / 注册 / JWT / 管理员种子
│ ├── config/ ← Viper 配置层
│ ├── database/ ← GORM + SQLite (WAL) 初始化
│ ├── model/ ← 数据模型 + AutoMigrate 注册
│ ├── repository/ ← 数据访问层
│ ├── service/ ← 业务逻辑(核心)
│ │ ├── auth.go 登录 / 注册 / JWT
│ │ ├── media.go 媒体库 + 媒体 CRUD
│ │ ├── scanner.go 文件扫描 + ffprobe + 刮削触发
│ │ ├── ffprobe.go ffprobe 封装
│ │ ├── tmdb.go TMDb 数据源
│ │ ├── bangumi.go Bangumi 数据源
│ │ ├── scraper.go 刮削协调器 + 文件名清洗
│ │ ├── site.go 站点管理(CRUD + 连接测试 + 跨站搜索)
│ │ ├── scanner.go 文件扫描 + ffprobe
│ │ ├── scraper.go 刮削调度 + 文件名清洗
│ │ ├── tmdb.go / bangumi.go 第三方数据源
│ │ ├── site.go 站点管理 CRUD + 跨站搜索
│ │ ├── site_adapter.go 6 种 PT 站点适配器
│ │ ├── stream.go 直链播放 + HLS 分片
│ │ ├── transcoder.go 媒体 HLS 转码管理
│ │ ├── subtitle.go 外挂字幕识别 + WebVTT 转换
│ │ ├── stream.go 直链 + HLS 播放
│ │ ├── transcoder.go ffmpeg 转码作业管理
│ │ ├── subtitle.go 外挂字幕 → WebVTT
│ │ ├── image_proxy.go 图片代理缓存
│ │ ├── playback.go 播放历史 / 收藏 / 播放列表
│ │ ├── watcher.go fsnotify 文件监听
│ │ ├── qbittorrent.go qBittorrent API 客户端
│ │ ├── downloads.go 下载管理 + WS 轮询
│ │ ├── downloads.go 下载管理
│ │ ├── subscription.go RSS 订阅轮询
│ │ ├── stats.go 仪表盘快照
│ │ ├── profile.go 用户信息修改
│ │ ├── organizer.go 媒体文件自动整理
│ │ ├── stats.go 系统仪表盘
│ │ ├── profile.go 用户信息
│ │ ├── audit.go 审计日志
│ │ ├── ws_hub.go WebSocket 发布/订阅
│ │ ├── organizer.go 媒体文件整理
│ │ └── walk.go / episode_parser.go 辅助工具
│ ├── middleware/ Gin 中间件 (CORS / JWT / admin)
│ └── handler/ HTTP 路由(按功能分文件)
├── web/ React 18 + Vite 前端
│ │ └── ws_hub.go WebSocket 发布/订阅
│ ├── middleware/ ← JWT / CORS / admin 中间件
│ └── handler/ ← HTTP 路由(按功能拆分)
├── web/ ← React 18 + Vite + Tailwind CSS
│ ├── src/api/ axios 接口封装
│ ├── src/components/ Layout / MediaCard / GlobalEvents / RequireAuth / APIConfigsPanel
│ ├── src/components/ 通用组件(Card / Layout / APIConfigsPanel)
│ ├── src/hooks/ useWebSocket 等
│ ├── src/pages/ 首页 / 媒体库 / 搜索 / 播放器 / 下载 / 管理后台 / 站点管理
│ ├── src/stores/ Zustand 状态管理 (auth)
│ └── src/types/ 前端类型定义(与 Go 模型对齐)
├── Dockerfile 多阶段、多架构构建
├── docker-compose.yml NAS 友好部署配置
├── Makefile build / dev / docker / test
├── config.example.yaml 完整配置模板
└── .github/workflows/ CI + GHCR 发布
│ ├── src/pages/ 首页 · 媒体库 · 搜索 · 播放器 · 下载 · 管理 · 站点
│ ├── src/stores/ Zustand(auth)
│ └── src/types/ 前端类型定义
├── Dockerfile ← 多阶段多架构构建
├── docker-compose.yml ← NAS 一键部署
├── Makefile ← build / dev / docker / test
├── config.example.yaml ← 完整配置模板
└── .github/workflows/ ← CI + GHCR 发布
```
---
## 许可证
## 🗺️ 路线图
基于 [GNU GPL v3.0](LICENSE) 开源发布。
| 特性 | 状态 |
|------|:---:|
| Jellyfin / Emby 双向兼容层 | 🔨 进行中 |
| DLNA / Chromecast 投屏 | 📋 计划中 |
| 在线字幕搜索 | 📋 计划中 |
| 多码率 ABR 转码 | 📋 计划中 |
| STRM 直链播放 (WebDAV / Alist / S3) | ✅ 已完成 |
---
## 🤝 贡献
欢迎提交 Issue 和 Pull Request!在提交 PR 之前请阅读 [贡献指南](CONTRIBUTING.md)。
---
## 📄 许可证
[GNU General Public License v3.0](LICENSE)
> ⚠️ 许可证授权功能由独立服务器 [MediaStationLicenseServer](https://github.com/ShukeBta/MediaStationLicenseServer) 管理,本项目不内置授权/验权逻辑。
---
<p align="center">
<sub>Made with ❤️ by MediaStationGo Team</sub>
</p>
+267 -151
View File
@@ -1,225 +1,341 @@
<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.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/MediaStationGo-Your_Private_Media_Center-111827?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0tMiAxNWwtNS01IDEuNDEtMS40MUwxMCAxNC4xN2w3LjU5LTcuNTlMMTkgOGwtOSA5eiIvPjwvc3ZnPg=="/>
<img src="https://img.shields.io/badge/MediaStationGo-Your_Private_Media_Center-1F2937?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0tMiAxNWwtNS01IDEuNDEtMS40MUwxMCAxNC4xN2w3LjU5LTcuNTlMMTkgOGwtOSA5eiIvPjwvc3ZnPg=="/>
</picture>
</p>
<h3 align="center"><samp>A Go rewrite of <a href="https://github.com/ShukeBta/MediaStation">MediaStation</a></samp></h3>
<h6 align="center"><samp>Lightweight · Fast · Single Binary · NAS Ready</samp></h6>
<p align="center">
<a href="README.md">中文</a>
<a href="README.md"><img src="https://img.shields.io/badge/中文-README-blue?style=flat-square" alt="Chinese"></a>
</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">
<img src="https://img.shields.io/badge/Go-1.25-00ADD8?style=for-the-badge&logo=go&logoColor=white" alt="Go">
<img src="https://img.shields.io/badge/React-18-61DAFB?style=for-the-badge&logo=react&logoColor=black" alt="React">
<img src="https://img.shields.io/badge/TypeScript-5-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript">
<img src="https://img.shields.io/badge/SQLite-WAL-003B57?style=for-the-badge&logo=sqlite&logoColor=white" alt="SQLite">
<img src="https://img.shields.io/badge/Docker-Alpine-2496ED?style=for-the-badge&logo=docker&logoColor=white" alt="Docker">
<img src="https://img.shields.io/badge/License-GPLv3-8B5CF6?style=for-the-badge&logo=gnu&logoColor=white" alt="GPL v3">
</p>
---
## 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.
<p align="center">
<b>📖 <a href="#-why-mediastationgo">Why</a></b>
&nbsp;·&nbsp;
<b>🚀 <a href="#-quick-start">Quick Start</a></b>
&nbsp;·&nbsp;
<b>✨ <a href="#-features">Features</a></b>
&nbsp;·&nbsp;
<b>🏗️ <a href="#-project-layout">Layout</a></b>
&nbsp;·&nbsp;
<b>⚙️ <a href="#-configuration">Config</a></b>
&nbsp;·&nbsp;
<b>🗺️ <a href="#-roadmap">Roadmap</a></b>
</p>
---
## Features
## 🤔 Why MediaStationGo?
### 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.)
> MediaStationGo is a from-scratch Go rewrite of [MediaStation](https://github.com/ShukeBta/MediaStation) — same full-featured media center experience, radically simpler deployment.
### 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
<table>
<tr>
<td width="50%">
### 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)
### Original MediaStation
- 🐍 Python / FastAPI + Vue
- 📦 Requires Python runtime & virtualenv
- 🐳 Docker mandatory or complex Python setup
- 📊 Deployment footprint > 500 MB
- 🔧 pip + npm dual build chains
### 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)
</td>
<td width="50%">
### 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)
### MediaStationGo ✨
- 🚀 Go 1.25 + React 18
- 📦 **Single static binary** (~30 MB)
- 🐳 Docker optional — runs natively bare-metal
- 🔥 Zero external dependencies (CGO off)
- ⚡ One-command build: `go build`
### 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
</td>
</tr>
</table>
### 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 | ⏳ |
| Metric | Original | MediaStationGo |
|--------|:---:|:---:|
| Binary size | — | ≈ 30 MB |
| Memory (idle) | ~200 MB | ~30 MB |
| Cold start | ~3s | ~0.3s |
| Deploy steps | 5+ | 1 |
| Frontend (gzip) | ~250 KB | ~83 KB |
---
## Quick Start
## ✨ Features
### Docker
<details open>
<summary><b>🔐 Authentication & Users</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| JWT dual-role auth | admin / user with refresh token support |
| One-click admin bootstrap | Auto-seeded `admin` / `admin123` on first run |
| Profile management | Email, avatar, password change |
| User admin panel | Role promotion / demotion, enable / disable |
| Audit log | Login, library ops, downloads — all tracked |
</details>
<details open>
<summary><b>📚 Library Management</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| Library CRUD | movie / tv / anime / music types supported |
| Recursive scanning | Filesystem walk + ffprobe metadata extraction |
| Smart filename parsing | Year + season/episode auto-detection |
| Multi-source scraping | TMDb → TheTVDB → Bangumi chain |
| HD poster upgrade | Optional Fanart.tv high-res fallback |
| Image proxy | TMDb / Bangumi / Douban / Fanart with disk cache |
| TV grouping | Season grouping with episode listing |
| Live fs watching | fsnotify-powered, 5-second coalesced debounce |
</details>
<details open>
<summary><b>🎬 Playback</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| Direct streaming | HTTP Range support for instant seeking |
| HLS on-demand | Per-media ffmpeg job with HW acceleration |
| External subtitles | .srt / .vtt / .ass / .ssa → real-time WebVTT |
| Resume playback | Auto-saved every 10s + Continue Watching on home |
| Favorites & playlists | One-tap toggle / ordered playlists (CRUD) |
</details>
<details open>
<summary><b>🌐 PT Site Management</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| 6 site types | nexusphp · gazelle · unit3d · mteam · discuz · custom_rss |
| 3 auth methods | Cookie / API Key / Auth Header |
| Site config | Full CRUD + connection test + enable toggle |
| Cross-site search | One-click search across all configured trackers |
| Extended config | Extra JSON: UA / RSS URL / timeout / priority / proxy / downloader |
</details>
<details open>
<summary><b>🤖 Automation</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| Download client | qBittorrent Web UI API (add / list / delete) |
| RSS subscriptions | Regex filter + GUID dedup + 10-min polling |
| File organizer | Auto-categorize downloads: move / copy / hardlink / symlink |
</details>
<details open>
<summary><b>📊 Operations & Monitoring</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| Live events | WebSocket push for scan / scrape / transcode / download / subscribe |
| Dashboard | CPU / Memory / Disk / Library counts / Goroutines |
| Task panel | Real-time ffmpeg jobs + qBittorrent torrents |
| NFO export | Kodi / Jellyfin compatible — single media or whole library |
| HW acceleration | Software / NVENC / Intel QSV / VAAPI encoder profiles |
| CI/CD | GitHub Actions + multi-arch GHCR release |
</details>
<details open>
<summary><b>🧠 AI & Discovery</b></summary>
<br>
| Feature | Description |
|---------|-------------|
| TMDb Discover | Trending / popular rails on homepage |
| AI smart search | OpenAI-compatible → natural language → structured query |
| AI recommendations | Personalized picks from your watch history |
</details>
---
## 🚀 Quick Start
### 🐳 Docker (Recommended)
```bash
git clone https://github.com/ShukeBta/MediaStationGo.git
cd MediaStationGo
# (optional) edit docker-compose.yml to mount your media root at /media
# Edit docker-compose.yml to mount your media at /media
docker compose up -d
```
Open <http://localhost:8080> and log in with `admin / admin123`.
> 🌐 Open <http://localhost:8080> and log in with `admin` / `admin123`.
### Bare Metal
### 💻 Bare Metal
| Prerequisite | Version |
|-------------|---------|
| Go | ≥ 1.25 |
| Node.js | ≥ 20 |
| FFmpeg | Any |
```bash
# requirements: Go 1.25+, Node 20+, ffmpeg
make build # produces bin/mediastation-go and web/dist
git clone https://github.com/ShukeBta/MediaStationGo.git
cd MediaStationGo
# Build backend + frontend
make build
# Start the server
./bin/mediastation-go
```
### Local Development
### 🛠️ Local Development
```bash
make dev # backend on :8080, MEDIASTATION_APP_DEBUG=true
make dev-web # vite dev server on :3000, proxies /api -> :8080
# Terminal 1: Go backend (port 8080, DEBUG mode)
make dev
# Terminal 2: Vite frontend (port 3000, proxies API calls)
make dev-web
```
---
## Configuration
## ⚙️ Configuration
Configuration is layered — defaults < `config.yaml` < `config/*.yaml` < environment variables prefixed with `MEDIASTATION_`.
Config precedence: **defaults** < `config.yaml` < `config/*.yaml` < **env vars** (prefix `MEDIASTATION_`)
### Most-Used Keys
### Key Environment Variables
| Key | Default | Purpose |
|-----|---------|---------|
| Variable | 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_APP_DATA_DIR` | `./data` | Data root (DB / cache / JWT) |
| `MEDIASTATION_APP_WEB_DIR` | `./web/dist` | SPA bundle directory |
| `MEDIASTATION_DATABASE_DB_PATH` | `./data/mediastation.db` | SQLite file path |
| `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 |
| `MEDIASTATION_SECRETS_TMDB_API_KEY` | *(empty)* | TMDb scraping (required) |
| `MEDIASTATION_SECRETS_BANGUMI_ACCESS_TOKEN` | *(empty)* | Bangumi rate limit boost |
| `MEDIASTATION_APP_CORS_ORIGINS` | *(empty)* | Allow-list (JSON array) |
| `ADMIN_INITIAL_PASSWORD` | `admin123` | Initial admin password |
### Runtime Settings (Admin → Settings)
### Runtime Settings
These live in the `settings` table and can be edited from the admin UI:
Admin panel → Settings tab, stored in the `settings` table:
| 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 |
| `qbittorrent.url` | qBittorrent Web UI URL |
| `qbittorrent.username` | Username |
| `qbittorrent.password` | Password |
| `qbittorrent.savepath` | Default save path (optional) |
After editing, hit **Downloads → Reload Config** (or `POST /api/downloads/reload`) so the qBittorrent client picks up the new credentials.
> 💡 After editing, hit **Downloads → Reload Config** or `POST /api/downloads/reload`.
See [`config.example.yaml`](config.example.yaml) for the full surface.
📖 Full config template: [`config.example.yaml`](config.example.yaml)
---
## Project Layout
## 🏗️ Project Layout
```
MediaStationGo/
├── cmd/server/main.go Application entry point
├── cmd/server/main.go ← 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
│ ├── config/ ← Viper configuration layer
│ ├── database/ ← GORM + SQLite (WAL) bootstrap
│ ├── model/ ← Data models + AutoMigrate registry
│ ├── repository/ ← Data access layer
│ ├── service/ ← Business logic (core)
│ │ ├── auth.go login / register / JWT
│ │ ├── 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
│ │ ├── scanner.go filesystem walker + ffprobe
│ │ ├── scraper.go scrape orchestrator + filename cleaner
│ │ ├── tmdb.go / bangumi.go third-party providers
│ │ ├── site.go site CRUD + cross-site search
│ │ ├── site_adapter.go 6 PT site adapters
│ │ ├── stream.go direct play + HLS
│ │ ├── transcoder.go per-media ffmpeg job manager
│ │ ├── subtitle.go external subs → WebVTT
│ │ ├── image_proxy.go cached image proxy
│ │ ├── playback.go history / favorites / playlists
│ │ ├── watcher.go fsnotify debouncer
│ │ ├── qbittorrent.go qBittorrent v2 API client
│ │ ├── downloads.go download orchestrator + WS poller
│ │ ├── downloads.go download orchestrator
│ │ ├── 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
│ │ ├── stats.go dashboard snapshot
│ │ ├── profile.go user profile mutations
│ │ ├── audit.go audit log writer
│ │ └── ws_hub.go WebSocket pub/sub broker
│ ├── middleware/ ← JWT / CORS / admin middleware
│ └── handler/ ← HTTP route definitions (by concern)
├── web/ ← React 18 + Vite + Tailwind CSS
│ ├── src/api/ axios service wrappers
│ ├── src/components/ Card / Layout / APIConfigsPanel / etc.
│ ├── src/hooks/ useWebSocket & friends
│ ├── 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
│ └── src/types/ TypeScript domain types
├── Dockerfile ← Multi-stage, multi-arch build
├── docker-compose.yml ← NAS-friendly one-command deploy
├── Makefile ← build / dev / docker / test
├── config.example.yaml ← Full configuration reference
└── .github/workflows/ ← CI + GHCR publish
```
---
## License
## 🗺️ Roadmap
Released under the [GNU GPL v3.0](LICENSE).
| Feature | Status |
|---------|:---:|
| Jellyfin / Emby compatibility layer | 🔨 In Progress |
| DLNA / Chromecast casting | 📋 Planned |
| Online subtitle search providers | 📋 Planned |
| Multi-bitrate ABR transcode | 📋 Planned |
| STRM direct streaming (WebDAV / Alist / S3) | ✅ Complete |
---
## 🤝 Contributing
Issues and PRs are welcome! Please read the [Contribution Guidelines](CONTRIBUTING.md) before submitting.
---
## 📄 License
[GNU General Public License v3.0](LICENSE)
> ⚠️ License activation/validation is handled by a separate server: [MediaStationLicenseServer](https://github.com/ShukeBta/MediaStationLicenseServer). This project contains no license generation or validation logic.
---
<p align="center">
<sub>Made with ❤️ by MediaStationGo Team</sub>
</p>