42 lines
662 B
Go
42 lines
662 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"os"
|
||
|
|
||
|
"github.com/BurntSushi/toml"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
BaseDir string
|
||
|
Format string
|
||
|
N_m3u8DLRE struct {
|
||
|
Path string
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var config Config
|
||
|
|
||
|
func loadConfig() {
|
||
|
configFile, err := os.Open("config.toml")
|
||
|
if err != nil {
|
||
|
fmt.Println("Error opening config file:", err)
|
||
|
return
|
||
|
}
|
||
|
defer configFile.Close()
|
||
|
|
||
|
byteValue, _ := io.ReadAll(configFile)
|
||
|
|
||
|
if _, err := toml.Decode(string(byteValue), &config); err != nil {
|
||
|
fmt.Println("Error decoding config file:", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if config.N_m3u8DLRE.Path == "" {
|
||
|
fmt.Println("Error: N_m3u8DL-RE path is not specified in the config file")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
}
|