feat(images): proxy external http(s) poster URLs; feat(players): accept 'kinopoisk_id' alias for Lumex

This commit is contained in:
Erno
2025-10-19 15:55:57 +00:00
parent 608eeb7dcf
commit e68ce7f114
2 changed files with 20 additions and 12 deletions

View File

@@ -36,7 +36,14 @@ func (h *ImagesHandler) GetImage(w http.ResponseWriter, r *http.Request) {
size = "original" size = "original"
} }
imageURL := fmt.Sprintf("%s/%s/%s", config.TMDBImageBaseURL, size, imagePath) var imageURL string
if strings.HasPrefix(imagePath, "http://") || strings.HasPrefix(imagePath, "https://") {
// Проксируем внешний абсолютный URL (например, Kinopoisk)
imageURL = imagePath
} else {
// TMDB относительный путь
imageURL = fmt.Sprintf("%s/%s/%s", config.TMDBImageBaseURL, size, imagePath)
}
resp, err := http.Get(imageURL) resp, err := http.Get(imageURL)
if err != nil { if err != nil {

View File

@@ -39,9 +39,10 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
return return
} }
if idType == "kinopoisk_id" { idType = "kp" }
if idType != "kp" && idType != "imdb" { if idType != "kp" && idType != "imdb" {
log.Printf("Error: invalid id_type: %s", idType) log.Printf("Error: invalid id_type: %s", idType)
http.Error(w, "id_type must be 'kp' or 'imdb'", http.StatusBadRequest) http.Error(w, "id_type must be 'kp' (kinopoisk_id) or 'imdb'", http.StatusBadRequest)
return return
} }