package main import ( "os/exec" "git.milar.in/milarin/channel" "git.milar.in/nyaanime/logic" "github.com/fsnotify/fsnotify" ) var Runner = InitializeRunner() func main() { // check for ffprobe in PATH if _, err := exec.LookPath("ffprobe"); err != nil { panic(err) // TODO error handling } // get access token once at startup to be sure that an access token is obtainable at all if _, err := logic.GetAnilistAccessToken(); err != nil { panic(err) // TODO error handling } logic.PrintPriorityTables() fileChan, err := WatchDirectory(fsnotify.Create, DownloadPath) if err != nil { panic(err) // TODO error handling } fileHandleChan := channel.Map(fileChan, NewFileHandle) workChan, logChan := channel.Tee(fileHandleChan) go channel.Each(workChan, HandleFileInRunner) channel.Each(logChan, PrintFileHandle) } func HandleFileInRunner(fh *FileHandle) { Runner.Run(func() { HandleFile(fh) }) }