2023-01-13 19:23:36 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-01-13 20:04:57 +01:00
|
|
|
"fmt"
|
|
|
|
|
2023-01-13 19:23:36 +01:00
|
|
|
"git.milar.in/nyaanime/logic"
|
|
|
|
"github.com/fsnotify/fsnotify"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
|
for file := range fsChan {
|
2023-01-13 20:04:57 +01:00
|
|
|
fileHandled := HandleFile(file)
|
|
|
|
|
2023-01-13 20:06:45 +01:00
|
|
|
if fileHandled {
|
|
|
|
fmt.Println("file handled:", file)
|
|
|
|
} else {
|
2023-01-13 20:05:47 +01:00
|
|
|
fmt.Println("file ignored:", file)
|
2023-01-13 20:04:57 +01:00
|
|
|
}
|
2023-01-13 19:23:36 +01:00
|
|
|
}
|
|
|
|
}
|