🚀 一个强大的Emby媒体服务器代理工具,支持123网盘直链播放,极致优化播放速度。
# 1. 下载docker-compose.yml
wget https://raw.githubusercontent.com/dydydd/panDirectServer/main/docker-compose.yml
# 2. 创建配置目录
mkdir -p config logs
# 3. 修改docker-compose.yml,使用预构建镜像
# 取消注释: image: ghcr.io/dydydd/pandirectserver:latest
# 注释掉: build 部分
# 4. 启动服务
docker-compose up -d
# 5. 访问管理界面
# 主服务: http://localhost:5245
# Emby代理: http://localhost:8096
# 克隆仓库(包含子模块)
git clone --recursive https://github.com/dydydd/panDirectServer.git
cd panDirectServer
# 启动服务
docker-compose up -d
# 1. 克隆仓库(包含子模块)
git clone --recursive https://github.com/dydydd/panDirectServer.git
cd panDirectServer
# 如果已经克隆但忘记了 --recursive,可以执行:
# git submodule update --init --recursive
# 2. 创建Python虚拟环境(可选但推荐)
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
# source venv/bin/activate
# 3. 安装基础依赖
pip install -r requirements.txt
# 4. 安装p123client(从子模块)
pip install -e ./p123client
# 5. 创建配置文件
mkdir -p config logs
cp config/config.json.example config/config.json
# 6. 编辑配置文件(填入你的123网盘和Emby信息)
# nano config/config.json # Linux/Mac
# notepad config\config.json # Windows
# 7. 启动服务
python app.py
如果不想使用Git子模块,可以直接从GitHub安装p123client:
# 1. 克隆仓库(不包含子模块)
git clone https://github.com/dydydd/panDirectServer.git
cd panDirectServer
# 2. 创建Python虚拟环境(可选但推荐)
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# 3. 安装所有依赖(包括从GitHub安装p123client)
pip install -r requirements.txt
pip install git+https://github.com/dydydd/p123client.git
# 4. 创建配置文件
mkdir -p config logs
cp config/config.json.example config/config.json
# 5. 编辑配置文件
# nano config/config.json
# 6. 启动服务
python app.py
创建 start.bat:
@echo off
cd /d %~dp0
if not exist venv (
python -m venv venv
call venv\Scripts\activate
pip install -r requirements.txt
pip install git+https://github.com/dydydd/p123client.git
)
call venv\Scripts\activate
python app.py
pause
双击 start.bat 即可启动服务。
创建 start.sh:
#!/bin/bash
cd "$(dirname "$0")"
if [ ! -d "venv" ]; then
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install git+https://github.com/dydydd/p123client.git
fi
source venv/bin/activate
python app.py
然后执行:
chmod +x start.sh
./start.sh
配置文件位于 config/config.json,首次启动会自动创建。
{
"123": {
"enable": true,
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"mount_path": "/123",
"download_mode": "direct",
"url_auth": {
"enable": true,
"secret_key": "YOUR_SECRET_KEY",
"uid": "YOUR_UID",
"expire_time": 3600,
"custom_domains": ["your-domain.com"]
}
},
"emby": {
"enable": true,
"server": "http://your-emby-server:8096",
"api_key": "YOUR_EMBY_API_KEY",
"port": 8096,
"path_mapping": {
"enable": true,
"from": "/your/emby/path",
"to": "/123"
}
},
"service": {
"port": 5245,
"external_url": "http://your-server.com:5245",
"log_level": "INFO"
}
}
| 配置项 | 说明 | 示例 |
|---|---|---|
client_id | 123网盘应用ID | "xxx" |
client_secret | 123网盘应用密钥 | "xxx" |
download_mode | 下载模式:direct(直链)或 proxy(代理) | "direct" |
url_auth.enable | 是否启用URL鉴权 | true |
url_auth.secret_key | URL鉴权密钥 | "xxx" |
url_auth.uid | 用户ID | "123456" |
url_auth.custom_domains | 自定义域名列表 | ["cdn.example.com"] |
| 配置项 | 说明 | 示例 |
|---|---|---|
server | Emby服务器地址 | "http://localhost:8096" |
api_key | Emby API密钥 | "xxx" |
port | Emby代理监听端口 | 8096 |
path_mapping.enable | 是否启用路径映射 | true |
path_mapping.from | Emby本地路径前缀 | "/mnt/media" |
path_mapping.to | 云盘路径前缀 | "/123" |
| 配置项 | 说明 | 示例 |
|---|---|---|
port | 主服务端口 | 5245 |
external_url | 外部访问地址(代理模式必需) | "http://server.com:5245" |
log_level | 日志级别:DEBUG, INFO, WARNING, ERROR | "INFO" |
配置123网盘URL鉴权:
secret_key 和 uid修改配置:
{
"123": {
"download_mode": "direct",
"url_auth": {
"enable": true,
"secret_key": "YOUR_SECRET",
"uid": "YOUR_UID",
"custom_domains": ["cdn.example.com"]
}
}
}
配置Emby路径映射:
{
"emby": {
"path_mapping": {
"enable": true,
"from": "/CloudNAS/123云盘",
"to": "/123"
}
}
}
重启服务,享受极速播放!
如果没有自定义域名,可使用代理模式:
{
"123": {
"download_mode": "proxy"
},
"service": {
"external_url": "http://your-server.com:5245"
}
}
⚠️ 注意:代理模式会消耗服务器带宽,速度较慢。
| 指标 | 直链模式 | 代理模式 |
|---|---|---|
| 首次播放 | 59-209ms | 100-300ms |
| 二次播放 | 6ms ⚡ | 100-200ms |
| 重启后 | 6ms ⚡ | 100-200ms |
| 服务器带宽 | 不消耗 | 100%消耗 |
| 推荐度 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
系统会自动记录 item_id → 文件路径 映射到 config/item_path_db.json:
{
"service": {
"log_level": "INFO" // DEBUG, INFO, WARNING, ERROR
}
}
访问 http://localhost:5245 可以:
GET http://localhost:5245/api/status
响应:
{
"code": 200,
"data": {
"service": {
"status": "running",
"port": 5245
},
"emby": {
"status": "running",
"port": 8096,
"server": "http://localhost:8096"
},
"123": {
"status": "connected"
}
}
}
# 获取配置
GET http://localhost:5245/api/config
# 更新配置
POST http://localhost:5245/api/config
Content-Type: application/json
{
"service": {...},
"emby": {...},
"123": {...}
}
docker build -t pandirectserver:latest .
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t pandirectserver:latest \
--push .
提交代码到GitHub后,会自动触发构建流程:
main 或 master 分支v1.0.0)镜像会推送到:
dydydd/pandirectserverghcr.io/dydydd/pandirectserver修改默认密码:
{
"service": {
"username": "your_username",
"password": "your_strong_password"
}
}
使用HTTPS:
限制访问:
欢迎提交Issue和Pull Request!
本项目采用 MIT 许可证。
本项目已完成全面的SQLite优化重构:
-- 标准关系型数据库表结构
emby_config -- Emby配置(独立字段)
pan123_config -- 123网盘配置(独立字段)
service_config -- 服务配置(独立字段)
item_path_mapping -- Item路径映射(6ms极速查询)
direct_link_cache -- 直链缓存(自动过期)
client_connections -- 客户端连接跟踪
user_history -- 用户活动历史
| 功能 | 优化前 | 优化后 | 提升倍数 |
|---|---|---|---|
| 播放响应 | 100-500ms | 6ms | 10-80倍 |
| 配置加载 | 100-200ms | 5-10ms | 10-40倍 |
| 错误降级 | 6-7秒 | 0.8-1.5秒 | 4-6倍 |
| 内存占用 | 45MB+ | 12MB | 减少73% |
⭐ 如果这个项目对您有帮助,请给个Star!
Content type
Image
Digest
sha256:baf84ed46…
Size
182.7 MB
Last updated
11 months ago
docker pull dydydd/pandirectserver