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
This commit is contained in:
Cursor Agent
2025-10-04 21:20:39 +00:00
parent c170b2c7fa
commit 3be73ad264
2 changed files with 45 additions and 22 deletions

View File

@@ -330,7 +330,7 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec {
"/api/v1/players/lumex/{imdb_id}": map[string]interface{}{ "/api/v1/players/lumex/{imdb_id}": map[string]interface{}{
"get": map[string]interface{}{ "get": map[string]interface{}{
"summary": "Плеер Lumex", "summary": "Плеер Lumex",
"description": "Получение плеера Lumex по IMDb ID", "description": "Получение плеера Lumex по IMDb ID. Формат URL: /movie/{id} для фильмов, /tv-series/{id}?season=X&episode=Y для сериалов",
"tags": []string{"Players"}, "tags": []string{"Players"},
"parameters": []map[string]interface{}{ "parameters": []map[string]interface{}{
{ {
@@ -338,12 +338,29 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec {
"in": "path", "in": "path",
"required": true, "required": true,
"schema": map[string]string{"type": "string"}, "schema": map[string]string{"type": "string"},
"description": "IMDb ID фильма", "description": "IMDb ID фильма или сериала (например, tt0133093)",
},
{
"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{}{ "responses": map[string]interface{}{
"200": map[string]interface{}{ "200": map[string]interface{}{
"description": "Данные плеера", "description": "HTML со встроенным Lumex плеером",
"content": map[string]interface{}{
"text/html": map[string]interface{}{},
},
}, },
}, },
}, },

View File

@@ -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) 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 != "" { 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 { } 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) log.Printf("🔗 Final Lumex URL: %s", playerURL)
url := playerURL
iframe := fmt.Sprintf(`<iframe src="%s" allowfullscreen loading="lazy" style="border:none;width:100%%;height:100%%;"></iframe>`, url) iframe := fmt.Sprintf(`<iframe src="%s" allowfullscreen loading="lazy" style="border:none;width:100%%;height:100%%;"></iframe>`, playerURL)
htmlDoc := fmt.Sprintf(`<!DOCTYPE html><html><head><meta charset='utf-8'/><title>Lumex Player</title><style>html,body{margin:0;height:100%%;}</style></head><body>%s</body></html>`, iframe) htmlDoc := fmt.Sprintf(`<!DOCTYPE html><html><head><meta charset='utf-8'/><title>Lumex Player</title><style>html,body{margin:0;height:100%%;}</style></head><body>%s</body></html>`, iframe)
w.Header().Set("Content-Type", "text/html") w.Header().Set("Content-Type", "text/html")