2022-04-27 00:19:05 -04:00
|
|
|
package app
|
2022-04-26 09:55:59 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Feeds []struct {
|
|
|
|
Name string `yaml:"name"`
|
|
|
|
Channel string `yaml:"channel"`
|
|
|
|
Rhash string `yaml:"rhash"`
|
|
|
|
Url string `yaml:"url"`
|
|
|
|
Cron string `yaml:"cron"`
|
|
|
|
Proxy string `yaml:"proxy"`
|
|
|
|
} `yaml:"feeds"`
|
|
|
|
}
|
|
|
|
|
2022-04-27 00:19:05 -04:00
|
|
|
func ParseConfig(configPath string) (*Config, error) {
|
|
|
|
cfg, err := os.ReadFile(configPath)
|
2022-04-26 09:55:59 -04:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
c := Config{}
|
|
|
|
err = yaml.Unmarshal(cfg, &c)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &c, nil
|
|
|
|
}
|