mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-28 03:06:38 +08:00
b0fe40142a
* Rebrand MMTL to MeBox across codebase and assets Rename the project display name, Go module path, environment variable prefix (MEBOX_*), Docker image references, and UI branding from MMTL/mmtl to MeBox/mebox. Replace logo assets with the new MeBox icon and keep legacy SQLite migration support for existing mmtl.db deployments. Co-authored-by: truewhile <truewhile@users.noreply.github.com> * Fix logo icons: use cube-only crop without truncated text Previous icon generation cropped too much of the source image, including partial MeBox wordmark text that was cut off in square icon containers. Regenerate logo-64/192/512, favicon, and SVG from cube-only region. Co-authored-by: truewhile <truewhile@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
100 lines
3.2 KiB
Go
100 lines
3.2 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/truewhile/MeBox/internal/model"
|
|
)
|
|
|
|
// 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)
|
|
}
|
|
}
|
|
|
|
func TestMapRemoteItemToMediaExtractsCodecsAndContainer(t *testing.T) {
|
|
r := &EmbyRemoteService{}
|
|
item := map[string]any{
|
|
"Id": "item-100",
|
|
"Name": "Test Movie",
|
|
"Container": "mkv",
|
|
"MediaStreams": []any{
|
|
map[string]any{
|
|
"Type": "Video",
|
|
"Codec": "h264",
|
|
"Width": 1920,
|
|
"Height": 1080,
|
|
},
|
|
map[string]any{
|
|
"Type": "Audio",
|
|
"Codec": "aac",
|
|
},
|
|
},
|
|
"MediaSources": []any{
|
|
map[string]any{
|
|
"Container": "mkv",
|
|
"Size": int64(104857600),
|
|
},
|
|
},
|
|
}
|
|
media := r.MapRemoteItemToMedia(t.Context(), nil, &model.StrmAccount{Base: model.Base{ID: "acct-1"}}, &EmbyRemoteConfig{}, item)
|
|
if media.Container != "mkv" {
|
|
t.Fatalf("media.Container = %v, want mkv", media.Container)
|
|
}
|
|
if media.VideoCodec != "h264" {
|
|
t.Fatalf("media.VideoCodec = %v, want h264", media.VideoCodec)
|
|
}
|
|
if media.AudioCodec != "aac" {
|
|
t.Fatalf("media.AudioCodec = %v, want aac", media.AudioCodec)
|
|
}
|
|
if media.Width != 1920 || media.Height != 1080 {
|
|
t.Fatalf("resolution = %dx%d, want 1920x1080", media.Width, media.Height)
|
|
}
|
|
if media.SizeBytes != 104857600 {
|
|
t.Fatalf("size = %d, want 104857600", media.SizeBytes)
|
|
}
|
|
}
|