0.2.68
This commit is contained in:
@@ -262,21 +262,40 @@ func (p Profile) TopGenres(n int) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// Score rates a candidate against the profile. A negative score means "exclude".
|
||||
func (p Profile) Score(candidate Item) float64 {
|
||||
// HasSeen reports whether this viewer has already watched or begun the candidate, by any
|
||||
// of the four things that can say so: the item itself, the series it belongs to, another
|
||||
// copy of the same title, and Emby's own user data on the payload.
|
||||
//
|
||||
// It is the veto half of [Score], separated because one caller needs the two halves apart:
|
||||
// the Magic pick treats "already seen" as a heavy penalty rather than an exclusion, since a
|
||||
// library whose owner has watched most of it must still be able to answer "put something
|
||||
// good on".
|
||||
func (p Profile) HasSeen(candidate Item) bool {
|
||||
if p.Seen[candidate.ID] {
|
||||
return -1
|
||||
return true
|
||||
}
|
||||
if candidate.SeriesID != "" && p.Seen[candidate.SeriesID] {
|
||||
return -1
|
||||
return true
|
||||
}
|
||||
if p.SeenTitles[candidate.SeenKey()] {
|
||||
return -1
|
||||
}
|
||||
if candidate.UserData.Played || candidate.UserData.PlaybackPositionTicks > 0 {
|
||||
return -1
|
||||
return true
|
||||
}
|
||||
return candidate.UserData.Played || candidate.UserData.PlaybackPositionTicks > 0
|
||||
}
|
||||
|
||||
// Score rates a candidate against the profile. A negative score means "exclude".
|
||||
func (p Profile) Score(candidate Item) float64 {
|
||||
if p.HasSeen(candidate) {
|
||||
return -1
|
||||
}
|
||||
return p.Affinity(candidate)
|
||||
}
|
||||
|
||||
// Affinity is what [Score] measures once the candidate has passed the seen veto: genre and
|
||||
// studio weight, a mild quality nudge and a small bonus for a recent production. Never
|
||||
// negative for a plausible candidate, which is what makes it usable as one term of a larger
|
||||
// sum rather than only as a verdict.
|
||||
func (p Profile) Affinity(candidate Item) float64 {
|
||||
var genreScore float64
|
||||
for _, genre := range candidate.Genres {
|
||||
genreScore += p.GenreWeights[strings.TrimSpace(genre)]
|
||||
|
||||
Reference in New Issue
Block a user