mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-02 12:26:36 +08:00
0eb3f104f4
- 新增 emby_remote 提供方:通过 STRM 账号体系配置远程 Emby 地址/用户名/密码
- EmbyService 聚合远程媒体库 Views/Items/详情/最近添加/全局搜索,远程数据不落库
- 条目 ID 统一伪装为 embyremote~{account}~{id},请求按账号路由回远程
- 播放支持账号级 proxy_play 配置:默认客户端直连远程;开启后由 MMTL 反向代理流/字幕
- 图片/元数据全部实时透传远程,播放状态(已看/收藏)透传回远程 Emby
- cloud 包新增 emby Provider(Ping/List/Resolve),账号测试/目录浏览自动生效
- 前端 STRM 页面支持 Emby 远程挂载账号(地址+凭据+代理开关)
54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// rewriteSubtitleDeliveryURLs 只应改动字幕轨道的 DeliveryUrl,其余媒体流不动。
|
|
func TestRewriteSubtitleDeliveryURLsProxyMode(t *testing.T) {
|
|
src := map[string]any{
|
|
"MediaStreams": []any{
|
|
map[string]any{"Type": "Video", "DeliveryUrl": "/Videos/x/stream"},
|
|
map[string]any{"Type": "Audio", "DeliveryUrl": "/Videos/x/stream"},
|
|
map[string]any{"Type": "Subtitle", "DeliveryUrl": "/Videos/item-1/ms-9/Subtitles/2/Stream.srt"},
|
|
},
|
|
}
|
|
rewriteSubtitleDeliveryURLs(src, "/Videos/embyremote~acct-1~item-1", &EmbyRemoteConfig{})
|
|
streams := src["MediaStreams"].([]any)
|
|
if got := streams[0].(map[string]any)["DeliveryUrl"]; got != "/Videos/x/stream" {
|
|
t.Fatalf("video DeliveryUrl must stay, got %v", got)
|
|
}
|
|
want := "/Videos/embyremote~acct-1~item-1/Subtitles/2/Stream.srt"
|
|
if got := streams[2].(map[string]any)["DeliveryUrl"]; got != want {
|
|
t.Fatalf("subtitle DeliveryUrl = %v, want %v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestRewriteSubtitleDeliveryURLsDirectMode(t *testing.T) {
|
|
src := map[string]any{
|
|
"MediaStreams": []any{
|
|
map[string]any{"Type": "Subtitle", "DeliveryUrl": "/Videos/item-1/ms-9/Subtitles/1/Stream.ass"},
|
|
},
|
|
}
|
|
cfg := &EmbyRemoteConfig{Token: "tok123"}
|
|
rewriteSubtitleDeliveryURLs(src, "http://remote:8096/emby/Videos/item-1", cfg)
|
|
streams := src["MediaStreams"].([]any)
|
|
want := "http://remote:8096/emby/Videos/item-1/Subtitles/1/Stream.ass?api_key=tok123"
|
|
if got := streams[0].(map[string]any)["DeliveryUrl"]; got != want {
|
|
t.Fatalf("subtitle DeliveryUrl = %v, want %v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestRewriteSubtitleDeliveryURLsFallsBackIndexOne(t *testing.T) {
|
|
src := map[string]any{
|
|
"MediaStreams": []any{
|
|
map[string]any{"Type": "Subtitle", "DeliveryUrl": "custom/url"},
|
|
},
|
|
}
|
|
rewriteSubtitleDeliveryURLs(src, "/Videos/embyremote~acct-1~item-1", &EmbyRemoteConfig{})
|
|
streams := src["MediaStreams"].([]any)
|
|
want := "/Videos/embyremote~acct-1~item-1/Subtitles/1/Stream"
|
|
if got := streams[0].(map[string]any)["DeliveryUrl"]; got != want {
|
|
t.Fatalf("subtitle DeliveryUrl = %v, want %v", got, want)
|
|
}
|
|
} |