just make it configurable
This commit is contained in:
parent
0ca8bff0e2
commit
8b47674ed7
2 changed files with 13 additions and 13 deletions
|
@ -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
|
||||
|
|
8
main.go
8
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue