Initial commit
This commit is contained in:
41
config.go
Normal file
41
config.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func getDownloadDir() string {
|
||||
value, exists := os.LookupEnv("YTDLP_SITE_DOWNLOAD_DIR")
|
||||
if exists {
|
||||
return value
|
||||
}
|
||||
return "downloads"
|
||||
}
|
||||
|
||||
func getConfigDir() string {
|
||||
value, exists := os.LookupEnv("YTDLP_SITE_CONFIG_DIR")
|
||||
if exists {
|
||||
return value
|
||||
}
|
||||
return "config"
|
||||
}
|
||||
|
||||
func getAdminInitialPassword() (string, error) {
|
||||
key := "YTDLP_SITE_ADMIN_INITIAL_PASSWORD"
|
||||
value, exists := os.LookupEnv(key)
|
||||
if exists {
|
||||
return value, nil
|
||||
}
|
||||
return "", errors.New(fmt.Sprintf("please set %s", key))
|
||||
}
|
||||
|
||||
func getSessionAuthKey() ([]byte, error) {
|
||||
key := "YTDLP_SITE_SESSION_AUTH_KEY"
|
||||
value, exists := os.LookupEnv(key)
|
||||
if exists {
|
||||
return []byte(value), nil
|
||||
}
|
||||
return []byte{}, errors.New(fmt.Sprintf("please set %s", key))
|
||||
}
|
Reference in New Issue
Block a user