Skip to content

feat: add MediaInfo fallback foundation - #7

Merged
InfinityPacer merged 2 commits into
mainfrom
feat/mediainfo-foundation
Aug 28, 2026
Merged

InfinityPacer merged 2 commits into
mainfrom
feat/mediainfo-foundation

Conversation

@InfinityPacer

Copy link
Copy Markdown
Owner

背景

Plex 为 STRM Part 返回的技术 MediaInfo 可能为空。直接在 metadata 请求中临时拼接远程探测会放大起播延迟,也无法在重启后复用结果。本 PR 先建立可独立审阅、默认 dormant 的分析基础层,为后续 response enrichment 和下一集预热提供稳定边界。

实现

  • 增加版本化 MediaInfo record、Provider descriptor 与 STRM fingerprint,短期 CDN URL 和凭据不进入持久身份。
  • 增加有界 HashiCorp LRU 与 SQLite WAL 持久缓存,支持 30 天 fresh、180 天 retention、stale 已知良好回退、访问续租和 GC。
  • 增加受限远程 ffprobe,约束 timeout、probesize、analyzeduration、输出大小和进程取消,并保留 HDR、Dolby Vision、Atmos、字幕等标准化字段。
  • 增加交互/后台双优先级队列、singleflight、负缓存、队列上限、快速切换提升和安全关闭。
  • 通过无需管理 Token 的 Plex /identity 隔离不同 PMS 的缓存记录;失败只停用 MediaInfo,不影响透明代理。
  • 增加 MediaInfo 健康摘要和固定结构指标;容器安装 ffprobe,以非 root UID/GID 1000 使用 /app_data 持久目录。
  • 引入真实 go.sum 并恢复 GitHub Actions Go module 缓存。
  • 调整路线:当前后续只实现精确当前项和确认播放后的一步下一集低优先预热,季、整剧和目录批量任务延后。

行为边界

  • 本 PR 尚不改写 Plex XML/JSON metadata,也不启用 5 秒冷等待。
  • 未提交任务时不会请求 MediaVault/CDN,也不会启动 ffprobe。
  • MediaInfo 初始化失败时,Gateway 继续透明代理 Plex。
  • decision、Part、universal start 和 302 数据路径不执行 ffprobe 或 SQLite I/O。
  • 不读取或写入 Plex SQLite,不需要管理 Token,不包含季、整剧或目录批量预热。

验证

go test -count=1 ./...
go test -race -count=1 ./...
go vet ./...
actionlint .github/workflows/*.yml
go mod verify
docker build -t plex-gateway:mediainfo-f1 .

隔离容器 smoke 额外确认:

  • /app_data 成功创建 SQLite WAL 文件;
  • 零任务状态下 MediaVault 请求数和 active probe 均为 0,容器中只有 Gateway 进程;
  • 指定不存在的 ffprobe 时,健康摘要报告 MediaInfo unavailable,普通 Plex 请求仍透明转发;
  • 独立实现 Review 最终 verdict 为 pass。

@InfinityPacer
InfinityPacer merged commit 71f8f9f into main Aug 28, 2026
1 check passed
@InfinityPacer
InfinityPacer deleted the feat/mediainfo-foundation branch August 28, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant