fix(emby): preserve cloud source paths in PlaybackInfo

Fixes #64
This commit is contained in:
ShukeBta
2026-08-10 19:20:22 +08:00
parent f436267572
commit c32f23a626
3 changed files with 55 additions and 12 deletions
+30 -2
View File
@@ -204,7 +204,6 @@ func (e *EmbyService) mediaSource(ctx context.Context, m *model.Media, asEmbedde
// follow the same STRM entry as generated .strm files; when disabled we
// expose /Videos/{id}/stream so playback uses the Emby 302/proxy path.
src["IsRemote"] = true
src["Path"] = playURL
}
return src
}
@@ -213,7 +212,7 @@ func (e *EmbyService) baseMediaSource(m *model.Media, container string, isCloud
return map[string]any{
"Id": m.ID,
"Name": m.Title,
"Path": m.Path,
"Path": embyMediaSourcePath(m),
"Container": container,
"Size": m.SizeBytes,
"Protocol": "Http",
@@ -231,6 +230,35 @@ func (e *EmbyService) baseMediaSource(m *model.Media, container string, isCloud
}
}
// embyMediaSourcePath keeps Emby's Path field as a source identity rather
// than a playback endpoint. OpenList and other path-based cloud providers
// carry the real provider path in the internal cloud-play ref query. For
// opaque provider refs, fall back to the display path stored in cloud://.
func embyMediaSourcePath(m *model.Media) string {
if m == nil {
return ""
}
if _, ref, ok := parseCloudMediaPlaybackURL(m.STRMURL); ok && strings.HasPrefix(ref, "/") {
return ref
}
raw := strings.TrimSpace(m.Path)
u, err := url.Parse(raw)
if err != nil || !strings.EqualFold(u.Scheme, "cloud") {
return m.Path
}
sourcePath := strings.TrimSpace(u.Path)
if decoded, decodeErr := url.PathUnescape(sourcePath); decodeErr == nil {
sourcePath = decoded
}
if sourcePath == "" {
return "/"
}
if !strings.HasPrefix(sourcePath, "/") {
sourcePath = "/" + sourcePath
}
return sourcePath
}
func embyMediaContainer(m *model.Media) string {
container := strings.Trim(strings.ToLower(m.Container), ". ")
if container == "" {