diff --git a/pkg/handlers/players.go b/pkg/handlers/players.go
index 8a3902b..ea64284 100644
--- a/pkg/handlers/players.go
+++ b/pkg/handlers/players.go
@@ -78,7 +78,8 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
var allohaResponse struct {
Status string `json:"status"`
Data struct {
- Iframe string `json:"iframe"`
+ TokenMovie string `json:"token_movie"`
+ Iframe string `json:"iframe"`
} `json:"data"`
}
@@ -88,22 +89,41 @@ func (h *PlayersHandler) GetAllohaPlayer(w http.ResponseWriter, r *http.Request)
return
}
- if allohaResponse.Status != "success" || allohaResponse.Data.Iframe == "" {
- log.Printf("Video not found or empty iframe")
+ if allohaResponse.Status != "success" {
+ log.Printf("Video not found")
http.Error(w, "Video not found", http.StatusNotFound)
return
}
- iframeCode := allohaResponse.Data.Iframe
- if !strings.Contains(iframeCode, "<") {
- iframeCode = fmt.Sprintf(``, iframeCode)
+ // Получаем параметры для сериалов
+ season := r.URL.Query().Get("season")
+ episode := r.URL.Query().Get("episode")
+ translation := r.URL.Query().Get("translation")
+ if translation == "" {
+ translation = "66" // дефолтная озвучка
}
- htmlDoc := fmt.Sprintf(`
Alloha Player%s`, 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
+ }
- // Авто-исправление экранированных кавычек
- htmlDoc = strings.ReplaceAll(htmlDoc, `\"`, `"`)
- htmlDoc = strings.ReplaceAll(htmlDoc, `\'`, `'`)
+ log.Printf("Generated Alloha player URL: %s", playerURL)
+
+ iframe := fmt.Sprintf(``, playerURL)
+ htmlDoc := fmt.Sprintf(`Alloha Player%s`, iframe)
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(htmlDoc))
@@ -132,8 +152,16 @@ 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)
+ // Получаем параметры для сериалов
+ 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(``, url)
htmlDoc := fmt.Sprintf(`Lumex Player%s`, iframe)
@@ -227,9 +255,24 @@ func (h *PlayersHandler) GetVibixPlayer(w http.ResponseWriter, r *http.Request)
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(``, 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(``, playerURL)
htmlDoc := fmt.Sprintf(`Vibix Player%s`, iframe)
w.Header().Set("Content-Type", "text/html")