0.2.54
This commit is contained in:
@@ -23,6 +23,7 @@ type requestCandidate struct {
|
||||
Overview string `json:"overview"`
|
||||
PosterURL string `json:"posterUrl,omitempty"`
|
||||
AlreadyAdded bool `json:"alreadyAdded"`
|
||||
InLibrary bool `json:"inLibrary"`
|
||||
}
|
||||
|
||||
type requestLookupResponse struct {
|
||||
@@ -99,6 +100,27 @@ func (s *Server) handleRequestLookup(w http.ResponseWriter, r *http.Request, ses
|
||||
}
|
||||
wg.Wait()
|
||||
candidates := append(movieCandidates, seriesCandidates...)
|
||||
movieIDs, seriesIDs := []int{}, []int{}
|
||||
for _, candidate := range candidates {
|
||||
if candidate.MediaType == "movie" {
|
||||
movieIDs = append(movieIDs, candidate.ForeignID)
|
||||
} else {
|
||||
seriesIDs = append(seriesIDs, candidate.ForeignID)
|
||||
}
|
||||
}
|
||||
moviesInLibrary, movieErr := s.store.LibraryContainsProviderIDs(r.Context(), "Tmdb", movieIDs)
|
||||
seriesInLibrary, seriesErr := s.store.LibraryContainsProviderIDs(r.Context(), "Tvdb", seriesIDs)
|
||||
if movieErr != nil || seriesErr != nil {
|
||||
s.loggerFor(r.Context()).Warn("request library status unavailable",
|
||||
"movie_error", movieErr, "series_error", seriesErr)
|
||||
}
|
||||
for index := range candidates {
|
||||
if candidates[index].MediaType == "movie" {
|
||||
candidates[index].InLibrary = moviesInLibrary[candidates[index].ForeignID]
|
||||
} else {
|
||||
candidates[index].InLibrary = seriesInLibrary[candidates[index].ForeignID]
|
||||
}
|
||||
}
|
||||
sort.SliceStable(candidates, func(i, j int) bool {
|
||||
return requestMatchScore(term, candidates[i].Title) < requestMatchScore(term, candidates[j].Title)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user