This commit is contained in:
ponzischeme89
2026-08-23 09:40:45 +12:00
parent 9a1f44da46
commit 766cea2199
19 changed files with 828 additions and 164 deletions
+21 -22
View File
@@ -444,28 +444,11 @@ func explainRecommendation(
compatibility compatibilityProfile,
browsed bool,
) (string, string) {
top := profile.TopGenres(5)
matched := ""
for _, wanted := range top {
for _, genre := range item.Genres {
if strings.EqualFold(wanted, genre) {
matched = genre
break
}
}
if matched != "" {
break
}
}
reasons := make([]string, 0, 3)
if browsed {
reasons = append(reasons, "You explored this recently")
} else if matched != "" {
reasons = append(reasons, "Matches your "+matched+" viewing")
} else if len(profile.Seeds) > 0 {
reasons = append(reasons, "Inspired by "+profile.Seeds[0].Name)
} else {
reasons = append(reasons, "Matches your recent viewing")
reasons = append(reasons, strongestPersonalReason(profile, item).Text)
}
if availableMinutes > 0 && item.RuntimeMinutes() > 0 {
reasons = append(reasons, "fits your "+strconv.Itoa(availableMinutes)+"-minute window")
@@ -758,7 +741,7 @@ func (e *Engine) buildCuratedRows(ctx context.Context, profile Profile, seed str
ID: definition.ID,
Title: definition.Title,
Kind: definition.Kind,
Items: Raws(items),
Items: enrichRecommendationReasons(profile, items),
})
}
return rows
@@ -1054,11 +1037,17 @@ func (e *Engine) similarRow(
return Row{}, false
}
items = diversifyRanked(items, variation+":similar:"+seed.ID, 5)
raws := make([]json.RawMessage, 0, len(items))
for _, item := range items {
raws = append(raws, enrichRecommendation(
item.Raw, "Because you watched "+seed.Name, "",
))
}
return Row{
ID: "similar:" + seed.ID,
Title: "Because you watched " + seed.Name,
Kind: "similar",
Items: Raws(items),
Items: raws,
}, true
}
@@ -1208,7 +1197,7 @@ func (e *Engine) historyRow(ctx context.Context, cred emby.Credentials, profile
ID: "recommended",
Title: "Recommended from your watching history",
Kind: "recommended",
Items: Raws(items),
Items: enrichRecommendationReasons(profile, items),
}, true
}
@@ -1240,6 +1229,16 @@ func (e *Engine) historyRow(ctx context.Context, cred emby.Credentials, profile
ID: "recommended",
Title: "Recommended from your watching history",
Kind: "recommended",
Items: Raws(items),
Items: enrichRecommendationReasons(profile, items),
}, true
}
func enrichRecommendationReasons(profile Profile, items []Item) []json.RawMessage {
raws := make([]json.RawMessage, 0, len(items))
for _, item := range items {
raws = append(raws, enrichRecommendation(
item.Raw, strongestPersonalReason(profile, item).Text, "",
))
}
return raws
}