subsyt/internal/config/config.go

37 lines
481 B
Go

package config
import (
"os"
toml "github.com/pelletier/go-toml/v2"
)
type Provider struct {
Url string
Throttle int
Video_items int
After_date string
}
type Config struct {
Out_dir string
Provider map[string]Provider
Dry_run bool
}
func Load(filepath string) (Config, error) {
data, err := os.ReadFile(filepath)
if err != nil {
panic(err)
}
cfg := Config{}
err = toml.Unmarshal(data, &cfg)
if err != nil {
panic(err)
}
return cfg, err
}