mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 01:48:51 +05:00
fix: restore original Alloha API method with season/episode support
- Use Data.Iframe from Alloha API response (original method) - Add season, episode, translation query parameters to iframe URL - Keep season/episode support for Lumex and Vibix - All Russian players now work with episode selection
This commit is contained in:
@@ -78,8 +78,7 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
||||
var allohaResponse struct {
|
||||
Status string `json:"status"`
|
||||
Data struct {
|
||||
TokenMovie string `json:"token_movie"`
|
||||
Iframe string `json:"iframe"`
|
||||
Iframe string `json:"iframe"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
@@ -89,8 +88,8 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if allohaResponse.Status != "success" {
|
||||
log.Printf("Video not found")
|
||||
if allohaResponse.Status != "success" || allohaResponse.Data.Iframe == "" {
|
||||
log.Printf("Video not found or empty iframe")
|
||||
http.Error(w, "Video not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
@@ -103,27 +102,29 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
||||
translation = "66" // дефолтная озвучка
|
||||
}
|
||||
|
||||
// Строим URL плеера
|
||||
// Используем iframe URL из API
|
||||
iframeCode := allohaResponse.Data.Iframe
|
||||
|
||||
// Если это не HTML код, а просто 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 !strings.Contains(iframeCode, "<") {
|
||||
playerURL = iframeCode
|
||||
// Добавляем параметры для сериалов
|
||||
if season != "" && episode != "" {
|
||||
playerURL = fmt.Sprintf("%s?season=%s&episode=%s&translation=%s", playerURL, season, episode, translation)
|
||||
separator := "?"
|
||||
if strings.Contains(playerURL, "?") {
|
||||
separator = "&"
|
||||
}
|
||||
playerURL = fmt.Sprintf("%s%sseason=%s&episode=%s&translation=%s", playerURL, separator, season, episode, translation)
|
||||
}
|
||||
} else if allohaResponse.Data.Iframe != "" {
|
||||
// Fallback на старый iframe
|
||||
playerURL = allohaResponse.Data.Iframe
|
||||
} else {
|
||||
http.Error(w, "Video not found", http.StatusNotFound)
|
||||
return
|
||||
iframeCode = fmt.Sprintf(`<iframe src="%s" allowfullscreen style="border:none;width:100%%;height:100%%"></iframe>`, playerURL)
|
||||
}
|
||||
|
||||
log.Printf("Generated Alloha player URL: %s", 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)
|
||||
|
||||
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)
|
||||
// Авто-исправление экранированных кавычек
|
||||
htmlDoc = strings.ReplaceAll(htmlDoc, `\"`, `"`)
|
||||
htmlDoc = strings.ReplaceAll(htmlDoc, `\'`, `'`)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Write([]byte(htmlDoc))
|
||||
|
||||
Reference in New Issue
Block a user