organizer/main.go

36 lines
764 B
Go
Raw Normal View History

2023-01-13 19:23:36 +01:00
package main
import (
2023-01-14 10:58:59 +01:00
"fmt"
"os/exec"
"strings"
"git.milar.in/milarin/channel"
2023-01-13 19:23:36 +01:00
"git.milar.in/nyaanime/logic"
"github.com/fsnotify/fsnotify"
)
func main() {
2023-01-14 10:58:59 +01:00
// check for ffprobe in PATH
if _, err := exec.LookPath("ffprobe"); err != nil {
panic(err) // TODO error handling
}
2023-01-13 19:23:36 +01:00
// 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
}
fsChan, err := WatchDirectory(fsnotify.Create, DownloadPath)
if err != nil {
panic(err) // TODO error handling
}
2023-01-14 10:58:59 +01:00
outputChan := channel.Map(fsChan, HandleFile)
channel.Each(outputChan, PrintStringBuilder)
}
func PrintStringBuilder(b *strings.Builder) {
fmt.Println(b.String())
2023-01-13 19:23:36 +01:00
}