mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 01:48:51 +05:00
feat: add season/episode support for Russian players
- Alloha: now uses token_movie API with season/episode params - Lumex: added season/episode query parameters - Vibix: added season/episode to iframe URL - All Russian players now support TV show episode selection - Better control over playback for series
This commit is contained in:
@@ -78,6 +78,7 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
|||||||
var allohaResponse struct {
|
var allohaResponse struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Data struct {
|
Data struct {
|
||||||
|
TokenMovie string `json:"token_movie"`
|
||||||
Iframe string `json:"iframe"`
|
Iframe string `json:"iframe"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
@@ -88,22 +89,41 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if allohaResponse.Status != "success" || allohaResponse.Data.Iframe == "" {
|
if allohaResponse.Status != "success" {
|
||||||
log.Printf("Video not found or empty iframe")
|
log.Printf("Video not found")
|
||||||
http.Error(w, "Video not found", http.StatusNotFound)
|
http.Error(w, "Video not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
iframeCode := allohaResponse.Data.Iframe
|
// Получаем параметры для сериалов
|
||||||
if !strings.Contains(iframeCode, "<") {
|
season := r.URL.Query().Get("season")
|
||||||
iframeCode = fmt.Sprintf(`<iframe src="%s" allowfullscreen style="border:none;width:100%%;height:100%%"></iframe>`, iframeCode)
|
episode := r.URL.Query().Get("episode")
|
||||||
|
translation := r.URL.Query().Get("translation")
|
||||||
|
if translation == "" {
|
||||||
|
translation = "66" // дефолтная озвучка
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
// Строим URL плеера
|
||||||
|
var playerURL string
|
||||||
|
if allohaResponse.Data.TokenMovie != "" {
|
||||||
|
// Используем новый API с token_movie
|
||||||
|
baseURL := "https://torso.as.allohafr.live"
|
||||||
|
playerURL = fmt.Sprintf("%s/%s", baseURL, allohaResponse.Data.TokenMovie)
|
||||||
|
if season != "" && episode != "" {
|
||||||
|
playerURL = fmt.Sprintf("%s?season=%s&episode=%s&translation=%s", playerURL, season, episode, translation)
|
||||||
|
}
|
||||||
|
} else if allohaResponse.Data.Iframe != "" {
|
||||||
|
// Fallback на старый iframe
|
||||||
|
playerURL = allohaResponse.Data.Iframe
|
||||||
|
} else {
|
||||||
|
http.Error(w, "Video not found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Авто-исправление экранированных кавычек
|
log.Printf("Generated Alloha player URL: %s", playerURL)
|
||||||
htmlDoc = strings.ReplaceAll(htmlDoc, `\"`, `"`)
|
|
||||||
htmlDoc = strings.ReplaceAll(htmlDoc, `\'`, `'`)
|
iframe := fmt.Sprintf(`<iframe src="%s" allowfullscreen loading="lazy" style="border:none;width:100%%;height:100%%;" allow="autoplay; encrypted-media; fullscreen"></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>`, iframe)
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
w.Write([]byte(htmlDoc))
|
w.Write([]byte(htmlDoc))
|
||||||
@@ -132,8 +152,16 @@ func (h *PlayersHandler) GetLumexPlayer(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("%s?imdb_id=%s", h.config.LumexURL, url.QueryEscape(imdbID))
|
// Получаем параметры для сериалов
|
||||||
log.Printf("Generated Lumex URL: %s", url)
|
season := r.URL.Query().Get("season")
|
||||||
|
episode := r.URL.Query().Get("episode")
|
||||||
|
|
||||||
|
playerURL := fmt.Sprintf("%s?imdb_id=%s", h.config.LumexURL, url.QueryEscape(imdbID))
|
||||||
|
if season != "" && episode != "" {
|
||||||
|
playerURL = fmt.Sprintf("%s&season=%s&episode=%s", playerURL, season, episode)
|
||||||
|
}
|
||||||
|
log.Printf("Generated 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>`, url)
|
||||||
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)
|
||||||
@@ -227,9 +255,24 @@ func (h *PlayersHandler) GetVibixPlayer(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Generated Vibix iframe URL: %s", vibixResponse.IframeURL)
|
// Получаем параметры для сериалов
|
||||||
|
season := r.URL.Query().Get("season")
|
||||||
|
episode := r.URL.Query().Get("episode")
|
||||||
|
|
||||||
iframe := fmt.Sprintf(`<iframe src="%s" allowfullscreen loading="lazy" style="border:none;width:100%%;height:100%%;"></iframe>`, vibixResponse.IframeURL)
|
// Строим итоговый URL плеера
|
||||||
|
playerURL := vibixResponse.IframeURL
|
||||||
|
if season != "" && episode != "" {
|
||||||
|
// Добавляем параметры сезона и серии
|
||||||
|
separator := "?"
|
||||||
|
if strings.Contains(playerURL, "?") {
|
||||||
|
separator = "&"
|
||||||
|
}
|
||||||
|
playerURL = fmt.Sprintf("%s%sseason=%s&episode=%s", playerURL, separator, season, episode)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Generated Vibix iframe URL: %s", playerURL)
|
||||||
|
|
||||||
|
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)
|
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")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
|
|||||||
Reference in New Issue
Block a user