mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 01:48:51 +05:00
Compare commits
19 Commits
e734e462c4
...
39c8366ae1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39c8366ae1 | ||
|
|
d47b4fd0a8 | ||
|
|
0d54aacc7d | ||
|
|
4e88529e0a | ||
|
|
0bd3a8860f | ||
|
|
5e761dbbc6 | ||
|
|
5d422231ca | ||
|
|
b467b7ed1c | ||
|
|
b76e8f685d | ||
|
|
3be73ad264 | ||
|
|
c170b2c7fa | ||
|
|
52d7e48bdb | ||
|
|
d4e29a8093 | ||
|
|
6ee4b8cc58 | ||
|
|
b20edae256 | ||
|
|
d29dce0afc | ||
|
|
39eea67323 | ||
|
|
bd853e7f89 | ||
|
|
4e6e447e79 |
31
api/index.go
31
api/index.go
@@ -97,6 +97,9 @@ func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
api.HandleFunc("/players/alloha/{imdb_id}", playersHandler.GetAllohaPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/lumex/{imdb_id}", playersHandler.GetLumexPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vibix/{imdb_id}", playersHandler.GetVibixPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vidsrc/{media_type}/{imdb_id}", playersHandler.GetVidsrcPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vidlink/movie/{imdb_id}", playersHandler.GetVidlinkMoviePlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vidlink/tv/{tmdb_id}", playersHandler.GetVidlinkTVPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/rgshows/{tmdb_id}", playersHandler.GetRgShowsPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/rgshows/{tmdb_id}/{season}/{episode}", playersHandler.GetRgShowsTVPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/iframevideo/{kinopoisk_id}/{imdb_id}", playersHandler.GetIframeVideoPlayer).Methods("GET")
|
||||
@@ -150,12 +153,30 @@ func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
protected.HandleFunc("/reactions/{mediaType}/{mediaId}", reactionsHandler.RemoveReaction).Methods("DELETE")
|
||||
protected.HandleFunc("/reactions/my", reactionsHandler.GetMyReactions).Methods("GET")
|
||||
|
||||
// CORS configuration - allow all origins
|
||||
corsHandler := handlers.CORS(
|
||||
handlers.AllowedOrigins([]string{"*"}),
|
||||
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}),
|
||||
handlers.AllowedHeaders([]string{"Authorization", "Content-Type", "Accept", "Origin", "X-Requested-With", "X-CSRF-Token"}),
|
||||
handlers.AllowCredentials(),
|
||||
handlers.ExposedHeaders([]string{"Authorization", "Content-Type"}),
|
||||
handlers.AllowedOrigins([]string{
|
||||
"*", // Allow all origins
|
||||
}),
|
||||
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH", "HEAD"}),
|
||||
handlers.AllowedHeaders([]string{
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"Accept",
|
||||
"Origin",
|
||||
"X-Requested-With",
|
||||
"X-CSRF-Token",
|
||||
"Access-Control-Allow-Origin",
|
||||
"Access-Control-Allow-Headers",
|
||||
"Access-Control-Allow-Methods",
|
||||
"Access-Control-Allow-Credentials",
|
||||
}),
|
||||
handlers.ExposedHeaders([]string{
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"X-Total-Count",
|
||||
}),
|
||||
handlers.MaxAge(3600),
|
||||
)
|
||||
|
||||
corsHandler(router).ServeHTTP(w, r)
|
||||
|
||||
31
main.go
31
main.go
@@ -78,6 +78,9 @@ func main() {
|
||||
api.HandleFunc("/players/alloha/{imdb_id}", playersHandler.GetAllohaPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/lumex/{imdb_id}", playersHandler.GetLumexPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vibix/{imdb_id}", playersHandler.GetVibixPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vidsrc/{media_type}/{imdb_id}", playersHandler.GetVidsrcPlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vidlink/movie/{imdb_id}", playersHandler.GetVidlinkMoviePlayer).Methods("GET")
|
||||
api.HandleFunc("/players/vidlink/tv/{tmdb_id}", playersHandler.GetVidlinkTVPlayer).Methods("GET")
|
||||
|
||||
api.HandleFunc("/torrents/search/{imdbId}", torrentsHandler.SearchTorrents).Methods("GET")
|
||||
api.HandleFunc("/torrents/movies", torrentsHandler.SearchMovies).Methods("GET")
|
||||
@@ -129,12 +132,30 @@ func main() {
|
||||
protected.HandleFunc("/reactions/{mediaType}/{mediaId}", reactionsHandler.RemoveReaction).Methods("DELETE")
|
||||
protected.HandleFunc("/reactions/my", reactionsHandler.GetMyReactions).Methods("GET")
|
||||
|
||||
// CORS configuration - allow all origins
|
||||
corsHandler := handlers.CORS(
|
||||
handlers.AllowedOrigins([]string{"*"}),
|
||||
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}),
|
||||
handlers.AllowedHeaders([]string{"Authorization", "Content-Type", "Accept", "Origin", "X-Requested-With", "X-CSRF-Token"}),
|
||||
handlers.AllowCredentials(),
|
||||
handlers.ExposedHeaders([]string{"Authorization", "Content-Type"}),
|
||||
handlers.AllowedOrigins([]string{
|
||||
"*", // Allow all origins
|
||||
}),
|
||||
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH", "HEAD"}),
|
||||
handlers.AllowedHeaders([]string{
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"Accept",
|
||||
"Origin",
|
||||
"X-Requested-With",
|
||||
"X-CSRF-Token",
|
||||
"Access-Control-Allow-Origin",
|
||||
"Access-Control-Allow-Headers",
|
||||
"Access-Control-Allow-Methods",
|
||||
"Access-Control-Allow-Credentials",
|
||||
}),
|
||||
handlers.ExposedHeaders([]string{
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"X-Total-Count",
|
||||
}),
|
||||
handlers.MaxAge(3600),
|
||||
)
|
||||
|
||||
var finalHandler http.Handler
|
||||
|
||||
@@ -327,31 +327,106 @@ 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. Не поддерживает выбор сезона/серии - плеер работает напрямую с 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": "Данные плеера",
|
||||
},
|
||||
"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{}{
|
||||
},
|
||||
"/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": "Vibix плеер по IMDb ID",
|
||||
"description": "Возвращает HTML-страницу с iframe Vibix для указанного IMDb ID",
|
||||
"summary": "Vidsrc плеер (английский)",
|
||||
"description": "Возвращает HTML-страницу с iframe Vidsrc.to. Использует IMDb ID для фильмов и сериалов. Пример URL для фильма: https://vidsrc.to/embed/movie/tt1234567, для сериала: https://vidsrc.to/embed/tv/tt6385540/1/1",
|
||||
"tags": []string{"Players"},
|
||||
"parameters": []map[string]interface{}{
|
||||
{
|
||||
"name": "media_type",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]interface{}{"type": "string", "enum": []string{"movie", "tv"}},
|
||||
"description": "Тип контента: movie (фильм) или tv (сериал)",
|
||||
},
|
||||
{
|
||||
"name": "imdb_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "string"},
|
||||
"description": "IMDb ID, например tt6385540 (с префиксом tt)",
|
||||
},
|
||||
{
|
||||
"name": "season",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер сезона (обязательно для TV)",
|
||||
},
|
||||
{
|
||||
"name": "episode",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер серии (обязательно для TV)",
|
||||
},
|
||||
},
|
||||
"responses": map[string]interface{}{
|
||||
"200": map[string]interface{}{
|
||||
"description": "HTML со встроенным Vidsrc плеером",
|
||||
"content": map[string]interface{}{
|
||||
"text/html": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"400": map[string]interface{}{"description": "Отсутствуют обязательные параметры"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v1/players/vidlink/movie/{imdb_id}": map[string]interface{}{
|
||||
"get": map[string]interface{}{
|
||||
"summary": "Vidlink плеер для фильмов (английский)",
|
||||
"description": "Возвращает HTML-страницу с iframe Vidlink.pro для фильмов. Использует IMDb ID. Пример URL: https://vidlink.pro/movie/tt1234567",
|
||||
"tags": []string{"Players"},
|
||||
"parameters": []map[string]interface{}{
|
||||
{
|
||||
@@ -359,18 +434,166 @@ func getOpenAPISpecWithURL(baseURL string) *OpenAPISpec {
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "string"},
|
||||
"description": "IMDb ID, например tt0133093",
|
||||
"description": "IMDb ID фильма, например tt1234567 (с префиксом tt)",
|
||||
},
|
||||
},
|
||||
"responses": map[string]interface{}{
|
||||
"200": map[string]interface{}{
|
||||
"description": "HTML со встроенным Vibix плеером",
|
||||
"description": "HTML со встроенным Vidlink плеером",
|
||||
"content": map[string]interface{}{
|
||||
"text/html": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"404": map[string]interface{}{"description": "Фильм не найден"},
|
||||
"503": map[string]interface{}{"description": "VIBIX_TOKEN не настроен"},
|
||||
"400": map[string]interface{}{"description": "IMDb ID не указан"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v1/players/vidlink/tv/{tmdb_id}": map[string]interface{}{
|
||||
"get": map[string]interface{}{
|
||||
"summary": "Vidlink плеер для сериалов (английский)",
|
||||
"description": "Возвращает HTML-страницу с iframe Vidlink.pro для сериалов. Использует TMDB ID (без префикса tt). Пример URL: https://vidlink.pro/tv/94997/1/1",
|
||||
"tags": []string{"Players"},
|
||||
"parameters": []map[string]interface{}{
|
||||
{
|
||||
"name": "tmdb_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "TMDB ID сериала, например 94997 (числовой идентификатор без префикса)",
|
||||
},
|
||||
{
|
||||
"name": "season",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер сезона (обязательно)",
|
||||
},
|
||||
{
|
||||
"name": "episode",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер серии (обязательно)",
|
||||
},
|
||||
},
|
||||
"responses": map[string]interface{}{
|
||||
"200": map[string]interface{}{
|
||||
"description": "HTML со встроенным Vidlink плеером",
|
||||
"content": map[string]interface{}{
|
||||
"text/html": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"400": map[string]interface{}{"description": "Отсутствуют обязательные параметры (tmdb_id, season, episode)"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v1/players/vidsrc-parse/{media_type}/{imdb_id}": map[string]interface{}{
|
||||
"get": map[string]interface{}{
|
||||
"summary": "Vidsrc плеер с парсингом (кастомный плеер)",
|
||||
"description": "Возвращает HTML-страницу с кастомным Video.js плеером. Автоматически извлекает m3u8 ссылку из Vidsrc.to через клиентский парсинг в iframe. Использует IMDb ID для фильмов и сериалов.",
|
||||
"tags": []string{"Players"},
|
||||
"parameters": []map[string]interface{}{
|
||||
{
|
||||
"name": "media_type",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]interface{}{"type": "string", "enum": []string{"movie", "tv"}},
|
||||
"description": "Тип контента: movie (фильм) или tv (сериал)",
|
||||
},
|
||||
{
|
||||
"name": "imdb_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "string"},
|
||||
"description": "IMDb ID, например tt6385540 (с префиксом tt)",
|
||||
},
|
||||
{
|
||||
"name": "season",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер сезона (обязательно для TV)",
|
||||
},
|
||||
{
|
||||
"name": "episode",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер серии (обязательно для TV)",
|
||||
},
|
||||
},
|
||||
"responses": map[string]interface{}{
|
||||
"200": map[string]interface{}{
|
||||
"description": "HTML с кастомным Video.js плеером и системой парсинга",
|
||||
"content": map[string]interface{}{
|
||||
"text/html": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"400": map[string]interface{}{"description": "Отсутствуют обязательные параметры"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v1/players/vidlink-parse/movie/{imdb_id}": map[string]interface{}{
|
||||
"get": map[string]interface{}{
|
||||
"summary": "Vidlink плеер с парсингом для фильмов (кастомный)",
|
||||
"description": "Возвращает HTML-страницу с кастомным Video.js плеером. Автоматически извлекает m3u8/mp4 ссылку из Vidlink.pro через клиентский парсинг. Использует 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 фильма, например tt1234567 (с префиксом tt)",
|
||||
},
|
||||
},
|
||||
"responses": map[string]interface{}{
|
||||
"200": map[string]interface{}{
|
||||
"description": "HTML с кастомным Video.js плеером и системой парсинга",
|
||||
"content": map[string]interface{}{
|
||||
"text/html": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"400": map[string]interface{}{"description": "IMDb ID не указан"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/v1/players/vidlink-parse/tv/{tmdb_id}": map[string]interface{}{
|
||||
"get": map[string]interface{}{
|
||||
"summary": "Vidlink плеер с парсингом для сериалов (кастомный)",
|
||||
"description": "Возвращает HTML-страницу с кастомным Video.js плеером. Автоматически извлекает m3u8/mp4 ссылку из Vidlink.pro через клиентский парсинг. Использует TMDB ID для сериалов.",
|
||||
"tags": []string{"Players"},
|
||||
"parameters": []map[string]interface{}{
|
||||
{
|
||||
"name": "tmdb_id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "TMDB ID сериала, например 94997 (числовой идентификатор без префикса)",
|
||||
},
|
||||
{
|
||||
"name": "season",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер сезона (обязательно)",
|
||||
},
|
||||
{
|
||||
"name": "episode",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": map[string]string{"type": "integer"},
|
||||
"description": "Номер серии (обязательно)",
|
||||
},
|
||||
},
|
||||
"responses": map[string]interface{}{
|
||||
"200": map[string]interface{}{
|
||||
"description": "HTML с кастомным Video.js плеером и системой парсинга",
|
||||
"content": map[string]interface{}{
|
||||
"text/html": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
"400": map[string]interface{}{"description": "Отсутствуют обязательные параметры (tmdb_id, season, episode)"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -94,9 +94,30 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
// Получаем параметры для сериалов
|
||||
season := r.URL.Query().Get("season")
|
||||
episode := r.URL.Query().Get("episode")
|
||||
translation := r.URL.Query().Get("translation")
|
||||
if translation == "" {
|
||||
translation = "66" // дефолтная озвучка
|
||||
}
|
||||
|
||||
// Используем iframe URL из API
|
||||
iframeCode := allohaResponse.Data.Iframe
|
||||
|
||||
// Если это не HTML код, а просто URL
|
||||
var playerURL string
|
||||
if !strings.Contains(iframeCode, "<") {
|
||||
iframeCode = fmt.Sprintf(`<iframe src="%s" allowfullscreen style="border:none;width:100%%;height:100%%"></iframe>`, iframeCode)
|
||||
playerURL = iframeCode
|
||||
// Добавляем параметры для сериалов
|
||||
if season != "" && episode != "" {
|
||||
separator := "?"
|
||||
if strings.Contains(playerURL, "?") {
|
||||
separator = "&"
|
||||
}
|
||||
playerURL = fmt.Sprintf("%s%sseason=%s&episode=%s&translation=%s", playerURL, separator, season, episode, translation)
|
||||
}
|
||||
iframeCode = fmt.Sprintf(`<iframe src="%s" allowfullscreen style="border:none;width:100%%;height:100%%"></iframe>`, playerURL)
|
||||
}
|
||||
|
||||
htmlDoc := fmt.Sprintf(`<!DOCTYPE html><html><head><meta charset='utf-8'/><title>Alloha Player</title><style>html,body{margin:0;height:100%%;}</style></head><body>%s</body></html>`, iframeCode)
|
||||
@@ -132,10 +153,11 @@ func (h *PlayersHandler) GetLumexPlayer(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s?imdb_id=%s", h.config.LumexURL, url.QueryEscape(imdbID))
|
||||
log.Printf("Generated Lumex URL: %s", url)
|
||||
// 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(`<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)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
@@ -227,9 +249,11 @@ func (h *PlayersHandler) GetVibixPlayer(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Generated Vibix iframe URL: %s", vibixResponse.IframeURL)
|
||||
// Vibix использует только iframe_url без season/episode
|
||||
playerURL := vibixResponse.IframeURL
|
||||
log.Printf("🔗 Vibix iframe URL: %s", playerURL)
|
||||
|
||||
iframe := fmt.Sprintf(`<iframe src="%s" allowfullscreen loading="lazy" style="border:none;width:100%%;height:100%%;"></iframe>`, vibixResponse.IframeURL)
|
||||
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>Vibix Player</title><style>html,body{margin:0;height:100%%;}</style></head><body>%s</body></html>`, iframe)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
@@ -435,3 +459,147 @@ func (h *PlayersHandler) GetStreamAPI(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
log.Printf("Successfully served stream API for provider: %s, tmdb_id: %s", provider, tmdbID)
|
||||
}
|
||||
|
||||
// GetVidsrcPlayer handles Vidsrc.to player (uses IMDb ID for both movies and TV shows)
|
||||
func (h *PlayersHandler) GetVidsrcPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GetVidsrcPlayer called: %s %s", r.Method, r.URL.Path)
|
||||
|
||||
vars := mux.Vars(r)
|
||||
imdbId := vars["imdb_id"]
|
||||
mediaType := vars["media_type"] // "movie" or "tv"
|
||||
|
||||
if imdbId == "" || mediaType == "" {
|
||||
http.Error(w, "imdb_id and media_type are required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
var playerURL string
|
||||
if mediaType == "movie" {
|
||||
playerURL = fmt.Sprintf("https://vidsrc.to/embed/movie/%s", imdbId)
|
||||
} else if mediaType == "tv" {
|
||||
season := r.URL.Query().Get("season")
|
||||
episode := r.URL.Query().Get("episode")
|
||||
if season == "" || episode == "" {
|
||||
http.Error(w, "season and episode are required for TV shows", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
playerURL = fmt.Sprintf("https://vidsrc.to/embed/tv/%s/%s/%s", imdbId, season, episode)
|
||||
} else {
|
||||
http.Error(w, "Invalid media_type. Use 'movie' or 'tv'", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Generated Vidsrc URL: %s", playerURL)
|
||||
|
||||
// Используем общий шаблон с кастомными контролами
|
||||
htmlDoc := getPlayerWithControlsHTML(playerURL, "Vidsrc Player")
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write([]byte(htmlDoc))
|
||||
|
||||
log.Printf("Successfully served Vidsrc player for %s: %s", mediaType, imdbId)
|
||||
}
|
||||
|
||||
// GetVidlinkMoviePlayer handles vidlink.pro player for movies (uses IMDb ID)
|
||||
func (h *PlayersHandler) GetVidlinkMoviePlayer(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GetVidlinkMoviePlayer called: %s %s", r.Method, r.URL.Path)
|
||||
|
||||
vars := mux.Vars(r)
|
||||
imdbId := vars["imdb_id"]
|
||||
|
||||
if imdbId == "" {
|
||||
http.Error(w, "imdb_id is required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
playerURL := fmt.Sprintf("https://vidlink.pro/movie/%s", imdbId)
|
||||
|
||||
log.Printf("Generated Vidlink Movie URL: %s", playerURL)
|
||||
|
||||
// Используем общий шаблон с кастомными контролами
|
||||
htmlDoc := getPlayerWithControlsHTML(playerURL, "Vidlink Player")
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write([]byte(htmlDoc))
|
||||
|
||||
log.Printf("Successfully served Vidlink movie player: %s", imdbId)
|
||||
}
|
||||
|
||||
// GetVidlinkTVPlayer handles vidlink.pro player for TV shows (uses TMDB ID)
|
||||
func (h *PlayersHandler) GetVidlinkTVPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GetVidlinkTVPlayer called: %s %s", r.Method, r.URL.Path)
|
||||
|
||||
vars := mux.Vars(r)
|
||||
tmdbId := vars["tmdb_id"]
|
||||
|
||||
if tmdbId == "" {
|
||||
http.Error(w, "tmdb_id is required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
season := r.URL.Query().Get("season")
|
||||
episode := r.URL.Query().Get("episode")
|
||||
if season == "" || episode == "" {
|
||||
http.Error(w, "season and episode are required for TV shows", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
playerURL := fmt.Sprintf("https://vidlink.pro/tv/%s/%s/%s", tmdbId, season, episode)
|
||||
|
||||
log.Printf("Generated Vidlink TV URL: %s", playerURL)
|
||||
|
||||
// Используем общий шаблон с кастомными контролами
|
||||
htmlDoc := getPlayerWithControlsHTML(playerURL, "Vidlink Player")
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write([]byte(htmlDoc))
|
||||
|
||||
log.Printf("Successfully served Vidlink TV player: %s S%sE%s", tmdbId, season, episode)
|
||||
}
|
||||
|
||||
// getPlayerWithControlsHTML возвращает HTML с плеером и overlay для блокировки кликов
|
||||
func getPlayerWithControlsHTML(playerURL, title string) string {
|
||||
return fmt.Sprintf(`<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'/>
|
||||
<title>%s</title>
|
||||
<style>
|
||||
html,body{margin:0;height:100%%;overflow:hidden;background:#000;font-family:Arial,sans-serif;}
|
||||
#container{position:relative;width:100%%;height:100%%;}
|
||||
#player-iframe{position:absolute;top:0;left:0;width:100%%;height:100%%;border:none;}
|
||||
#overlay{position:absolute;top:0;left:0;width:100%%;height:100%%;z-index:10;pointer-events:none;}
|
||||
#controls{position:absolute;bottom:0;left:0;right:0;background:linear-gradient(transparent,rgba(0,0,0,0.8));padding:20px;opacity:0;transition:opacity 0.3s;pointer-events:auto;z-index:20;}
|
||||
#container:hover #controls{opacity:1;}
|
||||
.btn{background:rgba(255,255,255,0.2);border:none;color:#fff;padding:12px 20px;margin:0 5px;border-radius:5px;cursor:pointer;font-size:16px;transition:background 0.2s;}
|
||||
.btn:hover{background:rgba(255,255,255,0.4);}
|
||||
.btn:active{background:rgba(255,255,255,0.6);}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<iframe id="player-iframe" src="%s" allowfullscreen allow="autoplay; encrypted-media; fullscreen; picture-in-picture"></iframe>
|
||||
<div id="overlay"></div>
|
||||
<div id="controls">
|
||||
<button class="btn" id="btn-fullscreen" title="Fullscreen">⛶ Fullscreen</button>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
const overlay=document.getElementById('overlay');
|
||||
|
||||
// Блокируем клики на iframe (защита от рекламы)
|
||||
overlay.addEventListener('click',(e)=>{e.preventDefault();e.stopPropagation();});
|
||||
overlay.addEventListener('mousedown',(e)=>{e.preventDefault();e.stopPropagation();});
|
||||
|
||||
// Fullscreen
|
||||
document.getElementById('btn-fullscreen').addEventListener('click',()=>{
|
||||
if(!document.fullscreenElement){
|
||||
document.getElementById('container').requestFullscreen();
|
||||
}else{
|
||||
document.exitFullscreen();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>`, title, playerURL)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user