47 lines
837 B
Go
47 lines
837 B
Go
|
|
// backend/config.go
|
||
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"path/filepath"
|
||
|
|
|
||
|
|
"scm.bstein.dev/bstein/Pegasus/backend/internal"
|
||
|
|
)
|
||
|
|
|
||
|
|
type appConfig struct {
|
||
|
|
mediaRoot string
|
||
|
|
userMapFile string
|
||
|
|
tusDir string
|
||
|
|
jf jellyfinClient
|
||
|
|
}
|
||
|
|
|
||
|
|
func loadAppConfig() appConfig {
|
||
|
|
mediaRoot := env("PEGASUS_MEDIA_ROOT", "/media")
|
||
|
|
return appConfig{
|
||
|
|
mediaRoot: mediaRoot,
|
||
|
|
userMapFile: env("PEGASUS_USER_MAP_FILE", "/config/user-map.yaml"),
|
||
|
|
tusDir: env("PEGASUS_TUS_DIR", filepath.Join(mediaRoot, ".pegasus-tus")),
|
||
|
|
jf: internal.NewJellyfin(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
var (
|
||
|
|
mediaRoot string
|
||
|
|
userMapFile string
|
||
|
|
tusDir string
|
||
|
|
jf jellyfinClient
|
||
|
|
)
|
||
|
|
|
||
|
|
var (
|
||
|
|
version = "dev"
|
||
|
|
git = ""
|
||
|
|
builtAt = ""
|
||
|
|
)
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
cfg := loadAppConfig()
|
||
|
|
mediaRoot = cfg.mediaRoot
|
||
|
|
userMapFile = cfg.userMapFile
|
||
|
|
tusDir = cfg.tusDir
|
||
|
|
jf = cfg.jf
|
||
|
|
}
|