diff --git a/configs/configs.go b/configs/configs.go index c7d7483..c68ca23 100644 --- a/configs/configs.go +++ b/configs/configs.go @@ -14,14 +14,16 @@ type DbConfig struct { Password string `json:"password"` } type Configs struct { - Chainquery DbConfig `json:"chainquery"` - Speech DbConfig `json:"speech"` - Voidwalker DbConfig `json:"voidwalker"` - ChannelID string `json:"channel_id"` - PublishAddress string `json:"publish_address"` - ReflectorServer string `json:"reflector_server"` - LbrynetTimeout time.Duration `json:"lbrynet_timeout"` - PreviousChannelIds []string `json:"previous_channel_ids"` + RedirectBaseURL string `json:"redirect_base_url"` + RedirectAdvancedURL string `json:"redirect_advanced_url"` + Chainquery DbConfig `json:"chainquery"` + Speech DbConfig `json:"speech"` + Voidwalker DbConfig `json:"voidwalker"` + ChannelID string `json:"channel_id"` + PublishAddress string `json:"publish_address"` + ReflectorServer string `json:"reflector_server"` + LbrynetTimeout time.Duration `json:"lbrynet_timeout"` + PreviousChannelIds []string `json:"previous_channel_ids"` } var Configuration *Configs diff --git a/main.go b/main.go index 84c8d60..22d78ad 100644 --- a/main.go +++ b/main.go @@ -121,11 +121,9 @@ func view(c *gin.Context) { return } - resizeParams := "" - redirectBaseURL := "https://source.thumbnails.odycdn.com/optimize/plain/https://player.odycdn.com/speech/" + redirectBaseURL := configs.Configuration.RedirectBaseURL if height != "" && width != "" { redirectBaseURL = "" - //resizeParams = fmt.Sprintf("&height=%s&width=%s&quality=80", height, width) desiredQuality := 80 if quality != "" { q, err := strconv.ParseInt(quality, 10, 32) @@ -133,11 +131,11 @@ func view(c *gin.Context) { desiredQuality = int(q) } } - redirectBaseURL = fmt.Sprintf("https://source.thumbnails.odycdn.com/optimize/s:%s:%s/quality:%d/plain/https://player.odycdn.com/speech/", width, height, desiredQuality) + redirectBaseURL = fmt.Sprintf(configs.Configuration.RedirectAdvancedURL, width, height, desiredQuality) } c.Header("Cache-Control", "max-age=604800") if parts := regexp.MustCompile(`^(view/)?([a-f0-9]+)/(.*?)\.(.*)$`).FindStringSubmatch(url); parts != nil { - c.Redirect(301, fmt.Sprintf("%s%s:%s.%s%s", redirectBaseURL, parts[3], parts[2], parts[4], resizeParams)) + c.Redirect(301, fmt.Sprintf("%s%s:%s.%s", redirectBaseURL, parts[3], parts[2], parts[4])) return }