From 3be73ad264ee06aa3139d55a9208e5df32a9af43 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 4 Oct 2025 21:20:39 +0000 Subject: [PATCH] fix: implement Lumex API with correct URL format - Use /movie/{id} for movies - Use /tv-series/{id}?season=X&episode=Y for TV shows - Keep route as /players/lumex/{imdb_id} - Add autoplay=1 parameter - Update API documentation with season/episode params - Keep IMDb ID in route but format URL according to Lumex API --- pkg/handlers/docs.go | 49 +++++++++++++++++++++++++++-------------- pkg/handlers/players.go | 18 ++++++++++----- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/pkg/handlers/docs.go b/pkg/handlers/docs.go index 6c326af..2a88d7c 100644 --- a/pkg/handlers/docs.go +++ b/pkg/handlers/docs.go @@ -327,27 +327,44 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec { }, }, }, - "/api/v1/players/lumex/{imdb_id}": map[string]interface{}{ - "get": map[string]interface{}{ - "summary": "Плеер Lumex", - "description": "Получение плеера Lumex по IMDb ID", - "tags": []string{"Players"}, - "parameters": []map[string]interface{}{ - { - "name": "imdb_id", - "in": "path", - "required": true, - "schema": map[string]string{"type": "string"}, - "description": "IMDb ID фильма", - }, + "/api/v1/players/lumex/{imdb_id}": map[string]interface{}{ + "get": map[string]interface{}{ + "summary": "Плеер Lumex", + "description": "Получение плеера Lumex по IMDb ID. Формат URL: /movie/{id} для фильмов, /tv-series/{id}?season=X&episode=Y для сериалов", + "tags": []string{"Players"}, + "parameters": []map[string]interface{}{ + { + "name": "imdb_id", + "in": "path", + "required": true, + "schema": map[string]string{"type": "string"}, + "description": "IMDb ID фильма или сериала (например, tt0133093)", }, - "responses": map[string]interface{}{ - "200": map[string]interface{}{ - "description": "Данные плеера", + { + "name": "season", + "in": "query", + "required": false, + "schema": map[string]string{"type": "integer"}, + "description": "Номер сезона (для сериалов)", + }, + { + "name": "episode", + "in": "query", + "required": false, + "schema": map[string]string{"type": "integer"}, + "description": "Номер серии (для сериалов)", + }, + }, + "responses": map[string]interface{}{ + "200": map[string]interface{}{ + "description": "HTML со встроенным Lumex плеером", + "content": map[string]interface{}{ + "text/html": map[string]interface{}{}, }, }, }, }, + }, "/api/v1/players/vibix/{imdb_id}": map[string]interface{}{ "get": map[string]interface{}{ "summary": "Vibix плеер по IMDb ID", diff --git a/pkg/handlers/players.go b/pkg/handlers/players.go index 767d57b..6eb9f86 100644 --- a/pkg/handlers/players.go +++ b/pkg/handlers/players.go @@ -159,17 +159,23 @@ func (h *PlayersHandler) GetLumexPlayer(w http.ResponseWriter, r *http.Request) log.Printf("🎬 Lumex Query Params - Season: '%s', Episode: '%s'", season, episode) - playerURL := fmt.Sprintf("%s?imdb_id=%s", h.config.LumexURL, url.QueryEscape(imdbID)) + // Lumex использует формат: + // Movie: {LUMEX_URL}/movie/{id}?autoplay=1 + // TV: {LUMEX_URL}/tv-series/{id}?season=1&episode=3&autoplay=1 + // ID может быть IMDb или числовым + var playerURL string if season != "" && episode != "" { - playerURL = fmt.Sprintf("%s&season=%s&episode=%s", playerURL, season, episode) - log.Printf("✅ Lumex: Added season/episode params") + // Сериал + playerURL = fmt.Sprintf("%s/tv-series/%s?season=%s&episode=%s&autoplay=1", h.config.LumexURL, imdbID, season, episode) + log.Printf("✅ Lumex: TV series mode with season/episode") } else { - log.Printf("⚠️ Lumex: No season/episode params (movie mode)") + // Фильм + playerURL = fmt.Sprintf("%s/movie/%s?autoplay=1", h.config.LumexURL, imdbID) + log.Printf("✅ Lumex: Movie mode") } log.Printf("🔗 Final Lumex URL: %s", playerURL) - url := playerURL - iframe := fmt.Sprintf(``, url) + iframe := fmt.Sprintf(``, playerURL) htmlDoc := fmt.Sprintf(`Lumex Player%s`, iframe) w.Header().Set("Content-Type", "text/html")