subsyt/internal/config/config.go
Viktor Varland c92fb61410
All checks were successful
build / build (push) Successful in 1m30s
refactor: use json for config to reach zero deps
2025-04-15 08:27:02 +02:00

49 lines
806 B
Go

package config
import (
"encoding/json"
"log"
"os"
)
type Provider struct {
Url string
Throttle int
Range string
After_date string
Cmd string
Cookies_file string
Opml_file string
Quality string
Output_path_template string
Po_token string
Verbose bool
Bgutil_server string
}
type Config struct {
Out_dir string
Provider map[string]Provider
Dry_run bool
Daemon bool
}
func Load(filepath string) (Config, error) {
data, err := os.ReadFile(filepath)
if err != nil {
panic(err)
}
cfg := Config{}
err = json.Unmarshal(data, &cfg)
if err != nil {
panic(err)
}
log.Println("Loaded config:")
log.Printf("%+v\n", cfg)
return cfg, err
}