✨ feat(video): 新增视频 CENC 解密与流式代理播放

- 逆向 SpadeA(黑桃A) PlayAuth 混淆,从 spade_a 还原 AES-128 内容密钥
- 实现 cenc-aes-ctr MP4 解密(senc 逐样本 CTR + stsd entry 修复),实测可播放
- 新增 /video/proxy/{key} 代理:稳定 key + 磁盘缓存(二次命中提速 130x)+
  http.ServeContent 支持 Range/206/seek 流式播放
- /video 接口新增 output(url/proxy,默认 proxy) 与 quality(max/720p/档位key) 参数,
  可由 config fanqie.video.* 配置默认值;无匹配清晰度时明确报错
- 代理映射复用 audio_cache 存储,抽取 loadMediaProxyEntry 共用;挂接 7 天缓存清理
- deploy.sh 新增 --sync-nginx:备份→重写→校验→失败自动回滚,同步视频代理段配置
This commit is contained in:
chenxin committed 2026-10-09 23:56:32 +08:00
1 parent 162dde9222
commit 0aed60713a
13 files changed
+1000 -78

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
package config
import (
"os"
"path/filepath"
"testing"
"github.com/spf13/viper"
)
// video 段配置读取:显式值生效、缺省回落 viper 默认值
func TestVideoConfig(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "config.yaml")
os.WriteFile(path, []byte(`
fanqie:
video:
output_mode: "proxy"
quality: "720p"
`), 0644)
v := viper.New()
v.SetConfigFile(path)
if err := v.ReadInConfig(); err != nil {
t.Fatal(err)
}
var c Config
if err := v.Unmarshal(&c); err != nil {
t.Fatal(err)
}
if c.Fanqie.Video.OutputMode != "proxy" || c.Fanqie.Video.Quality != "720p" {
t.Fatalf("显式配置未生效: %+v", c.Fanqie.Video)
}
// 缺省回落
v2 := viper.New()
v2.SetDefault("fanqie.video.output_mode", "url")
v2.SetDefault("fanqie.video.quality", "")
var c2 Config
if err := v2.Unmarshal(&c2); err != nil {
t.Fatal(err)
}
if c2.Fanqie.Video.OutputMode != "url" || c2.Fanqie.Video.Quality != "" {
t.Fatalf("默认值不符: %+v", c2.Fanqie.Video)
}
}