From 0bd3a8860f9b3956edfd28d64880c7582385e3fc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 4 Oct 2025 21:49:07 +0000 Subject: [PATCH] fix: remove season/episode support from Lumex and Vibix - Remove season/episode parameters from Lumex (not supported by API) - Remove season/episode parameters from Vibix (not working properly) - Improve redirect protection for English players: * Block window.close * Override window.location with getters/setters * Add mousedown event blocking * Add location change monitoring (100ms interval) * Prevent all forms of navigation - Update API documentation to reflect changes - Simplify player handlers code --- pkg/handlers/docs.go | 62 ++++++++++++++++------------------------- pkg/handlers/players.go | 62 ++++++++--------------------------------- 2 files changed, 35 insertions(+), 89 deletions(-) diff --git a/pkg/handlers/docs.go b/pkg/handlers/docs.go index 2a88d7c..5c25f5f 100644 --- a/pkg/handlers/docs.go +++ b/pkg/handlers/docs.go @@ -330,7 +330,7 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec { "/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 для сериалов", + "description": "Получение плеера Lumex по IMDb ID. Не поддерживает выбор сезона/серии - плеер работает напрямую с IMDb ID", "tags": []string{"Players"}, "parameters": []map[string]interface{}{ { @@ -340,20 +340,6 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec { "schema": map[string]string{"type": "string"}, "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{}{ "200": map[string]interface{}{ @@ -365,32 +351,32 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec { }, }, }, - "/api/v1/players/vibix/{imdb_id}": map[string]interface{}{ - "get": map[string]interface{}{ - "summary": "Vibix плеер по IMDb ID", - "description": "Возвращает HTML-страницу с iframe Vibix для указанного 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, например tt0133093", - }, - }, - "responses": map[string]interface{}{ - "200": map[string]interface{}{ - "description": "HTML со встроенным Vibix плеером", - "content": map[string]interface{}{ - "text/html": map[string]interface{}{}, - }, - }, - "404": map[string]interface{}{"description": "Фильм не найден"}, - "503": map[string]interface{}{"description": "VIBIX_TOKEN не настроен"}, + "/api/v1/players/vibix/{imdb_id}": map[string]interface{}{ + "get": map[string]interface{}{ + "summary": "Vibix плеер по IMDb ID", + "description": "Возвращает HTML-страницу с iframe Vibix для указанного IMDb ID. Не поддерживает выбор сезона/серии - плеер работает напрямую с 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, например tt0133093", }, }, + "responses": map[string]interface{}{ + "200": map[string]interface{}{ + "description": "HTML со встроенным Vibix плеером", + "content": map[string]interface{}{ + "text/html": map[string]interface{}{}, + }, + }, + "404": map[string]interface{}{"description": "Фильм не найден"}, + "503": map[string]interface{}{"description": "VIBIX_TOKEN не настроен"}, + }, }, + }, "/api/v1/players/vidsrc/{media_type}/{imdb_id}": map[string]interface{}{ "get": map[string]interface{}{ "summary": "Vidsrc плеер (английский)", diff --git a/pkg/handlers/players.go b/pkg/handlers/players.go index fd6091c..662e4b2 100644 --- a/pkg/handlers/players.go +++ b/pkg/handlers/players.go @@ -153,26 +153,9 @@ func (h *PlayersHandler) GetLumexPlayer(w http.ResponseWriter, r *http.Request) return } - // Получаем параметры для сериалов - season := r.URL.Query().Get("season") - episode := r.URL.Query().Get("episode") - - log.Printf("🎬 Lumex Query Params - Season: '%s', Episode: '%s'", season, episode) - - // Lumex использует формат: - // Movie: {LUMEX_URL}?imdb_id={imdb_id} - // TV: {LUMEX_URL}?imdb_id={imdb_id}&season=1&episode=3 - var playerURL string - if season != "" && episode != "" { - // Сериал - playerURL = fmt.Sprintf("%s?imdb_id=%s&season=%s&episode=%s", h.config.LumexURL, imdbID, season, episode) - log.Printf("✅ Lumex: TV series mode with season/episode") - } else { - // Фильм - playerURL = fmt.Sprintf("%s?imdb_id=%s", h.config.LumexURL, imdbID) - log.Printf("✅ Lumex: Movie mode") - } - log.Printf("🔗 Final Lumex URL: %s", playerURL) + // Lumex использует только IMDb ID без season/episode + playerURL := fmt.Sprintf("%s?imdb_id=%s", h.config.LumexURL, imdbID) + log.Printf("🔗 Lumex URL: %s", playerURL) iframe := fmt.Sprintf(``, playerURL) htmlDoc := fmt.Sprintf(`Lumex Player%s`, iframe) @@ -266,32 +249,9 @@ func (h *PlayersHandler) GetVibixPlayer(w http.ResponseWriter, r *http.Request) return } - // Получаем параметры для сериалов - season := r.URL.Query().Get("season") - episode := r.URL.Query().Get("episode") - - log.Printf("🎬 Vibix Query Params - Season: '%s', Episode: '%s'", season, episode) - log.Printf("🔗 Vibix Base iframe_url: %s", vibixResponse.IframeURL) - - // Строим итоговый URL плеера + // Vibix использует только iframe_url без season/episode playerURL := vibixResponse.IframeURL - if season != "" && episode != "" { - // Добавляем параметры сезона и серии - separator := "?" - if strings.Contains(playerURL, "?") { - separator = "&" - log.Printf("✅ Vibix: iframe_url already has query params, using '&'") - } else { - log.Printf("✅ Vibix: iframe_url has no query params, using '?'") - } - playerURL = fmt.Sprintf("%s%sseason=%s&episode=%s", playerURL, separator, season, episode) - log.Printf("✅ Vibix: Added season/episode params") - } else { - log.Printf("⚠️ Vibix: No season/episode params (movie mode)") - } - log.Printf("🔗 Final Vibix URL: %s", playerURL) - - log.Printf("Generated Vibix iframe URL: %s", playerURL) + log.Printf("🔗 Vibix iframe URL: %s", playerURL) iframe := fmt.Sprintf(``, playerURL) htmlDoc := fmt.Sprintf(`Vibix Player%s`, iframe) @@ -531,9 +491,9 @@ func (h *PlayersHandler) GetVidsrcPlayer(w http.ResponseWriter, r *http.Request) log.Printf("Generated Vidsrc URL: %s", playerURL) - // Продвинутая защита от всплывающих окон и редиректов + // Максимальная защита от всплывающих окон и редиректов iframe := fmt.Sprintf(``, playerURL) - htmlDoc := fmt.Sprintf(`Vidsrc Player%s`, iframe) + htmlDoc := fmt.Sprintf(`Vidsrc Player%s`, iframe) w.Header().Set("Content-Type", "text/html") w.Write([]byte(htmlDoc)) @@ -557,9 +517,9 @@ func (h *PlayersHandler) GetVidlinkMoviePlayer(w http.ResponseWriter, r *http.Re log.Printf("Generated Vidlink Movie URL: %s", playerURL) - // Продвинутая защита от всплывающих окон и редиректов + // Максимальная защита от всплывающих окон и редиректов iframe := fmt.Sprintf(``, playerURL) - htmlDoc := fmt.Sprintf(`Vidlink Player%s`, iframe) + htmlDoc := fmt.Sprintf(`Vidlink Player%s`, iframe) w.Header().Set("Content-Type", "text/html") w.Write([]byte(htmlDoc)) @@ -590,9 +550,9 @@ func (h *PlayersHandler) GetVidlinkTVPlayer(w http.ResponseWriter, r *http.Reque log.Printf("Generated Vidlink TV URL: %s", playerURL) - // Продвинутая защита от всплывающих окон и редиректов + // Максимальная защита от всплывающих окон и редиректов iframe := fmt.Sprintf(``, playerURL) - htmlDoc := fmt.Sprintf(`Vidlink Player%s`, iframe) + htmlDoc := fmt.Sprintf(`Vidlink Player%s`, iframe) w.Header().Set("Content-Type", "text/html") w.Write([]byte(htmlDoc))