package main import ( "os" "os/exec" "time" "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 } if err := InitTelegramBot(); err != nil { panic(err) // TODO error handling } //anime := adverr.Must(logic.SearchAnimeByTitle("トモちゃんは女の子!")) //animeEp1 := model.AnimeEpisode{Anime: anime, Episode: 2} //animeEp2 := model.AnimeEpisode{Anime: anime, Episode: 3} //animeEp3 := model.AnimeEpisode{Anime: anime, Episode: 4} //PrepareTelegramAnimeEpMessage(animeEp1) //PrepareTelegramAnimeEpMessage(animeEp2) //PrepareTelegramAnimeEpMessage(animeEp3) time.Sleep(time.Minute) os.Exit(0) 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) }) }