MeteorLight/config.go

42 lines
1.1 KiB
Go
Raw Normal View History

2022-03-01 23:31:29 +00:00
package main
import "github.com/BurntSushi/toml"
type Config struct {
Api struct {
Host string `toml:"host"`
Port int `toml:"port"`
2022-03-01 23:31:29 +00:00
} `toml:"api"`
Queue struct {
RandomSongApi string `toml:"random_song_api"`
NowPlaying string `toml:"np"`
NowRandom string `toml:"nr"`
2022-03-01 23:31:29 +00:00
FallbackPath string `toml:"fallback"`
BufferLengthInKiB int `toml:"buffer_len"`
BufferSeconds int `toml:"buffer_size"`
ReplayGain bool `toml:"replaygain"`
2022-03-01 23:31:29 +00:00
} `toml:"queue"`
Radio struct {
Port int `toml:"port"`
Name string `toml:"name"`
Description string `toml:"description"`
URL string `toml:"url"`
Logo string `toml:"logo"`
Private bool `toml:"private"`
2022-03-01 23:31:29 +00:00
} `toml:"radio"`
Streams []struct {
MountPath string `toml:"mount"`
Container string `toml:"container"`
Bitrate interface{} `toml:"bitrate"`
Codec string `toml:"codec"`
} `toml:"streams"`
}
func GetConfig(pathName string) (*Config, error) {
config := &Config{}
if _, err := toml.DecodeFile(pathName, config); err != nil {
return nil, err
}
return config, nil
}