优化客户端封面获取逻辑

修改emby客户端获取封面逻辑,修复没有设置封面导致封面为空的问题
This commit is contained in:
truewhile
2026-08-20 09:20:42 +08:00
parent 0d9ba2c33a
commit 541de2165e
7 changed files with 68725 additions and 4 deletions
+9 -3
View File
@@ -137,12 +137,12 @@ func (e *EmbyService) Views(ctx context.Context, userID string) (map[string]any,
if !e.libraryVisibleFromCachedVisibility(l, visibility) {
continue
}
items = append(items, e.libraryAsView(&l))
items = append(items, e.libraryAsView(ctx, &l))
}
return map[string]any{"Items": items, "TotalRecordCount": len(items), "StartIndex": 0}, nil
}
func (e *EmbyService) libraryAsView(l *model.Library) map[string]any {
func (e *EmbyService) libraryAsView(ctx context.Context, l *model.Library) map[string]any {
collectionType := "movies"
switch l.Type {
case "tv":
@@ -154,6 +154,12 @@ func (e *EmbyService) libraryAsView(l *model.Library) map[string]any {
case "music":
collectionType = "music"
}
// 库封面:与剧集/电影一样,只有在能解析出封面时才广告 ImageTags.Primary,
// 否则客户端会认为该库无主图而不去请求 /Images/Primary。
imageTags := map[string]string{}
if e.LibraryHasCover(ctx, l.ID) {
imageTags["Primary"] = l.ID
}
return map[string]any{
"Id": l.ID,
"Name": l.Name,
@@ -178,7 +184,7 @@ func (e *EmbyService) libraryAsView(l *model.Library) map[string]any {
"ProviderIds": map[string]string{},
"Genres": []string{},
"Tags": []string{},
"ImageTags": map[string]string{},
"ImageTags": imageTags,
"BackdropImageTags": []string{},
"UserData": map[string]any{
"PlaybackPositionTicks": 0,