From e46e16f8c9e66e4b6783e0d3ee2e1874f26781a8 Mon Sep 17 00:00:00 2001 From: nite07 Date: Wed, 23 Oct 2024 17:11:52 +0800 Subject: [PATCH] u --- config/config.go | 14 +++++++------- main.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/config.go b/config/config.go index 6d7857d..43ee0db 100644 --- a/config/config.go +++ b/config/config.go @@ -41,8 +41,8 @@ type PlayConfig struct { type Config struct { Input []any `json:"input"` - inputItems []InputItem `json:"-"` // contains video file or dir - PlayList []InputItem `json:"-"` // only contains video file + InputItems []InputItem `json:"-"` // contains video file or dir + VideoList []InputItem `json:"-"` // only contains video file Play PlayConfig `json:"play"` Output OutputConfig `json:"output"` } @@ -52,18 +52,18 @@ var GlobalConfig Config func init() { GlobalConfig = Config{} err := readConfig("config.json") - for i, item := range GlobalConfig.inputItems { + for i, item := range GlobalConfig.InputItems { if item.ItemType == "file" { - GlobalConfig.PlayList = append(GlobalConfig.PlayList, item) + GlobalConfig.VideoList = append(GlobalConfig.VideoList, item) } else if item.ItemType == "dir" { videos, err := getAllVideos(item.Path) if err != nil { log.Fatalf("input[%v] walk error: %v", i, err) } - GlobalConfig.PlayList = append(GlobalConfig.PlayList, videos...) + GlobalConfig.VideoList = append(GlobalConfig.VideoList, videos...) } } - if len(GlobalConfig.PlayList) == 0 { + if len(GlobalConfig.VideoList) == 0 { log.Fatal("No input video found") } if err != nil { @@ -122,7 +122,7 @@ func validateInputConfig() error { return fmt.Errorf("video_path[%v] is not supported", i) } } - GlobalConfig.inputItems = append(GlobalConfig.inputItems, inputItem) + GlobalConfig.InputItems = append(GlobalConfig.InputItems, inputItem) } } return nil diff --git a/main.go b/main.go index d945d46..e56c86e 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ func main() { if !utils.HasFFMPEG() { log.Fatal("ffmpeg not found") } - GlobalStreamer = streamer.NewStreamer(config.GlobalConfig.PlayList) + GlobalStreamer = streamer.NewStreamer(config.GlobalConfig.VideoList) go input() go startWatcher() GlobalStreamer.Stream() @@ -54,7 +54,7 @@ func startWatcher() { } defer watcher.Close() - for _, item := range config.GlobalConfig.PlayList { + for _, item := range config.GlobalConfig.InputItems { if item.ItemType == "dir" { err = watcher.Add(item.Path) if err != nil {