mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-27 17:38:51 +05:00
fix(search): force KP for ru language in multi search
- MultiSearch returns KP results when lang starts with ru - No fallback to TMDB for ru; KP errors bubble up
This commit is contained in:
@@ -30,9 +30,18 @@ func (h *SearchHandler) MultiSearch(w http.ResponseWriter, r *http.Request) {
|
||||
page := getIntQuery(r, "page", 1)
|
||||
language := GetLanguage(r)
|
||||
|
||||
if services.ShouldUseKinopoisk(language) && h.kpService != nil {
|
||||
if services.ShouldUseKinopoisk(language) {
|
||||
if h.kpService == nil {
|
||||
http.Error(w, "Kinopoisk service is not configured", http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
|
||||
kpSearch, err := h.kpService.SearchFilms(query, page)
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
|
||||
tmdbResp := services.MapKPSearchToTMDBResponse(kpSearch)
|
||||
multiResults := make([]models.MultiSearchResult, 0)
|
||||
for _, movie := range tmdbResp.Results {
|
||||
@@ -64,8 +73,8 @@ func (h *SearchHandler) MultiSearch(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// EN/прочие языки — TMDB
|
||||
results, err := h.tmdbService.SearchMulti(query, page, language)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user