mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-27 17:38:51 +05:00
fix(kp): url-escape keyword and imdbId in Kinopoisk requests to avoid 502
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -139,7 +140,7 @@ func (s *KinopoiskService) GetFilmByKinopoiskId(id int) (*KPFilm, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *KinopoiskService) GetFilmByImdbId(imdbId string) (*KPFilm, error) {
|
func (s *KinopoiskService) GetFilmByImdbId(imdbId string) (*KPFilm, error) {
|
||||||
endpoint := fmt.Sprintf("%s/v2.2/films?imdbId=%s", s.baseURL, imdbId)
|
endpoint := fmt.Sprintf("%s/v2.2/films?imdbId=%s", s.baseURL, url.QueryEscape(imdbId))
|
||||||
|
|
||||||
var response struct {
|
var response struct {
|
||||||
Films []KPFilm `json:"items"`
|
Films []KPFilm `json:"items"`
|
||||||
@@ -158,7 +159,7 @@ func (s *KinopoiskService) GetFilmByImdbId(imdbId string) (*KPFilm, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *KinopoiskService) SearchFilms(keyword string, page int) (*KPSearchResponse, error) {
|
func (s *KinopoiskService) SearchFilms(keyword string, page int) (*KPSearchResponse, error) {
|
||||||
endpoint := fmt.Sprintf("%s/v2.1/films/search-by-keyword?keyword=%s&page=%d", s.baseURL, keyword, page)
|
endpoint := fmt.Sprintf("%s/v2.1/films/search-by-keyword?keyword=%s&page=%d", s.baseURL, url.QueryEscape(keyword), page)
|
||||||
var response KPSearchResponse
|
var response KPSearchResponse
|
||||||
err := s.makeRequest(endpoint, &response)
|
err := s.makeRequest(endpoint, &response)
|
||||||
return &response, err
|
return &response, err
|
||||||
|
|||||||
Reference in New Issue
Block a user