34 lines
816 B
Go
34 lines
816 B
Go
package main
|
|
|
|
import "github.com/BurntSushi/toml"
|
|
|
|
type Config struct {
|
|
Api struct {
|
|
Port int `toml:"port"`
|
|
} `toml:"api"`
|
|
Queue struct {
|
|
RandomSongApi string `toml:"random_song_api"`
|
|
NowPlaying string `toml:"np"`
|
|
FallbackPath string `toml:"fallback"`
|
|
BufferLengthInKiB int `toml:"buffer_len"`
|
|
} `toml:"queue"`
|
|
Radio struct {
|
|
Port int `toml:"port"`
|
|
Name string `toml:"name"`
|
|
} `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
|
|
}
|