diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index af358cf..8f5b2ea 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -13,12 +13,21 @@ import ( // failureBackoff is how long we skip a file after processFn returned an error // for it, provided the file has not been touched since (mtime unchanged). Chosen // to be much larger than the polling interval so a permanently-broken input -// (e.g. video-only mkv producing "no audio streams found") does not spam the +// (e.g. a video-only file producing "no audio streams found") does not spam the // log every tick, but short enough that an operator who fixes the underlying // problem by replacing the file sees it picked up promptly on the next stable // scan. const failureBackoff = 5 * time.Minute +// inputExtensions lists the source container extensions the watcher will pick +// up. Globbed case-sensitively (matching prior .mkv behavior). +var inputExtensions = []string{ + "mkv", "mp4", "m4v", "mov", "avi", + "ts", "m2ts", "mts", + "mpg", "mpeg", "vob", + "webm", "wmv", "flv", +} + // fileStat is the (mtime, size) pair used to decide whether a file has settled // between two consecutive ticks. type fileStat struct { @@ -78,10 +87,14 @@ func (w *Watcher) Start(ctx context.Context, processFn func(context.Context, str } func (w *Watcher) scanAndProcess(ctx context.Context, processFn func(context.Context, string) error) { - files, err := filepath.Glob(filepath.Join(w.inputDir, "*.mkv")) - if err != nil { - fmt.Printf("Error scanning input directory: %v\n", err) - return + var files []string + for _, ext := range inputExtensions { + matches, err := filepath.Glob(filepath.Join(w.inputDir, "*."+ext)) + if err != nil { + fmt.Printf("Error scanning input directory: %v\n", err) + return + } + files = append(files, matches...) } now := time.Now()