just make it configurable
This commit is contained in:
parent
0ca8bff0e2
commit
8b47674ed7
2 changed files with 13 additions and 13 deletions
|
@ -14,6 +14,8 @@ type DbConfig struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
type Configs struct {
|
type Configs struct {
|
||||||
|
RedirectBaseURL string `json:"redirect_base_url"`
|
||||||
|
RedirectAdvancedURL string `json:"redirect_advanced_url"`
|
||||||
Chainquery DbConfig `json:"chainquery"`
|
Chainquery DbConfig `json:"chainquery"`
|
||||||
Speech DbConfig `json:"speech"`
|
Speech DbConfig `json:"speech"`
|
||||||
Voidwalker DbConfig `json:"voidwalker"`
|
Voidwalker DbConfig `json:"voidwalker"`
|
||||||
|
|
8
main.go
8
main.go
|
@ -121,11 +121,9 @@ func view(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeParams := ""
|
redirectBaseURL := configs.Configuration.RedirectBaseURL
|
||||||
redirectBaseURL := "https://source.thumbnails.odycdn.com/optimize/plain/https://player.odycdn.com/speech/"
|
|
||||||
if height != "" && width != "" {
|
if height != "" && width != "" {
|
||||||
redirectBaseURL = ""
|
redirectBaseURL = ""
|
||||||
//resizeParams = fmt.Sprintf("&height=%s&width=%s&quality=80", height, width)
|
|
||||||
desiredQuality := 80
|
desiredQuality := 80
|
||||||
if quality != "" {
|
if quality != "" {
|
||||||
q, err := strconv.ParseInt(quality, 10, 32)
|
q, err := strconv.ParseInt(quality, 10, 32)
|
||||||
|
@ -133,11 +131,11 @@ func view(c *gin.Context) {
|
||||||
desiredQuality = int(q)
|
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")
|
c.Header("Cache-Control", "max-age=604800")
|
||||||
if parts := regexp.MustCompile(`^(view/)?([a-f0-9]+)/(.*?)\.(.*)$`).FindStringSubmatch(url); parts != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue