fix: Emby 远程挂载播放地址强制下发 + 凭据状态显示修正

- PlaybackInfo 始终构造 DirectStreamUrl(远程 PlaybackInfo 默认不带该字段,
  此前客户端拿不到播放地址):默认指向远程 Emby 原地址(不代理),
  开启代理时指向 MMTL /Videos/{encoded} 反代端点
- HasStrmAccountCredential 对 emby_remote 放宽为 url+用户名/密码 即视为
  已配置(此前只认 api_key,导致列表误显示「凭据:未配置」)
This commit is contained in:
truewhile
2026-09-01 11:06:36 +08:00
parent f0055b76fe
commit 6af0e5fdcf
2 changed files with 8 additions and 5 deletions
+5 -3
View File
@@ -406,6 +406,9 @@ func (r *EmbyRemoteService) RemotePlaybackInfo(ctx context.Context, acct *model.
} }
// rewritePlayURLs 按代理模式重写载荷内 MediaSources 的播放地址。 // rewritePlayURLs 按代理模式重写载荷内 MediaSources 的播放地址。
// 远程 Emby 的 PlaybackInfo 通常不返回 DirectStreamUrl(客户端靠它拼
// /Videos/{Id}/stream),因此这里总是强制构造播放地址,完全由 MMTL 掌控
// 直连(远程绝对 URL)或代理(本地 /Videos/{encoded})的最终去向。
func (r *EmbyRemoteService) rewritePlayURLs(value any, acct *model.StrmAccount, cfg *EmbyRemoteConfig, remoteID string) { func (r *EmbyRemoteService) rewritePlayURLs(value any, acct *model.StrmAccount, cfg *EmbyRemoteConfig, remoteID string) {
encoded := EncodeEmbyRemoteID(acct.ID, remoteID) encoded := EncodeEmbyRemoteID(acct.ID, remoteID)
sources := collectMediaSources(value) sources := collectMediaSources(value)
@@ -426,9 +429,8 @@ func (r *EmbyRemoteService) rewritePlayURLs(value any, acct *model.StrmAccount,
} }
subtitlePlayURL = base + "/Videos/" + url.PathEscape(remoteID) subtitlePlayURL = base + "/Videos/" + url.PathEscape(remoteID)
} }
if _, exists := src["DirectStreamUrl"]; exists { // 直连/代理地址总是下发(PlaybackInfo 语义:客户端直接请求该 URL)。
src["DirectStreamUrl"] = streamPath src["DirectStreamUrl"] = streamPath
}
if _, exists := src["TranscodingUrl"]; exists { if _, exists := src["TranscodingUrl"]; exists {
src["TranscodingUrl"] = streamPath src["TranscodingUrl"] = streamPath
} }
+3 -2
View File
@@ -273,9 +273,10 @@ func HasStrmAccountCredential(acct *model.StrmAccount) bool {
case model.StrmProviderOpenList: case model.StrmProviderOpenList:
return strings.Contains(acct.Config, `"token"`) || strings.Contains(acct.Config, `"password"`) return strings.Contains(acct.Config, `"token"`) || strings.Contains(acct.Config, `"password"`)
case model.StrmProviderEmbyRemote: case model.StrmProviderEmbyRemote:
// 远程 Emby:已保存接入地址与认证凭据(自动认证得到的 token 或手动 api_key)。 // 远程 Emby:接入地址 + (自动认证凭据 或 手动 api_key) 即视为已配置。
return strings.Contains(acct.Config, `"url"`) && return strings.Contains(acct.Config, `"url"`) &&
(strings.Contains(acct.Config, `"token"`) || strings.Contains(acct.Config, `"api_key"`)) (strings.Contains(acct.Config, `"token"`) || strings.Contains(acct.Config, `"api_key"`) ||
(strings.Contains(acct.Config, `"username"`) && strings.Contains(acct.Config, `"password"`)))
default: default:
return strings.Contains(acct.Config, `"password"`) || strings.Contains(acct.Config, `"token"`) return strings.Contains(acct.Config, `"password"`) || strings.Contains(acct.Config, `"token"`)
} }