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,7 +78,6 @@ 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"`
|
||||||
}
|
}
|
||||||
@@ -89,8 +88,8 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if allohaResponse.Status != "success" {
|
if allohaResponse.Status != "success" || allohaResponse.Data.Iframe == "" {
|
||||||
log.Printf("Video not found")
|
log.Printf("Video not found or empty iframe")
|
||||||
http.Error(w, "Video not found", http.StatusNotFound)
|
http.Error(w, "Video not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -103,27 +102,29 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
|
|||||||
translation = "66" // дефолтная озвучка
|
translation = "66" // дефолтная озвучка
|
||||||
}
|
}
|
||||||
|
|
||||||
// Строим URL плеера
|
// Используем iframe URL из API
|
||||||
|
iframeCode := allohaResponse.Data.Iframe
|
||||||
|
|
||||||
|
// Если это не HTML код, а просто URL
|
||||||
var playerURL string
|
var playerURL string
|
||||||
if allohaResponse.Data.TokenMovie != "" {
|
if !strings.Contains(iframeCode, "<") {
|
||||||
// Используем новый API с token_movie
|
playerURL = iframeCode
|
||||||
baseURL := "https://torso.as.allohafr.live"
|
// Добавляем параметры для сериалов
|
||||||
playerURL = fmt.Sprintf("%s/%s", baseURL, allohaResponse.Data.TokenMovie)
|
|
||||||
if season != "" && episode != "" {
|
if season != "" && episode != "" {
|
||||||
playerURL = fmt.Sprintf("%s?season=%s&episode=%s&translation=%s", playerURL, season, episode, translation)
|
separator := "?"
|
||||||
|
if strings.Contains(playerURL, "?") {
|
||||||
|
separator = "&"
|
||||||
}
|
}
|
||||||
} else if allohaResponse.Data.Iframe != "" {
|
playerURL = fmt.Sprintf("%s%sseason=%s&episode=%s&translation=%s", playerURL, separator, season, episode, translation)
|
||||||
// Fallback на старый iframe
|
}
|
||||||
playerURL = allohaResponse.Data.Iframe
|
iframeCode = fmt.Sprintf(`<iframe src="%s" allowfullscreen style="border:none;width:100%%;height:100%%"></iframe>`, playerURL)
|
||||||
} else {
|
|
||||||
http.Error(w, "Video not found", http.StatusNotFound)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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.Header().Set("Content-Type", "text/html")
|
||||||
w.Write([]byte(htmlDoc))
|
w.Write([]byte(htmlDoc))
|
||||||
|
|||||||
Reference in New Issue
Block a user