MAL progress fetch

This commit is contained in:
daru
2022-04-18 02:53:09 +02:00
parent 8fe7bf4d4b
commit 994bccb068
7 changed files with 125 additions and 18 deletions

View File

@@ -27,7 +27,33 @@ func Arbeit() {
}
}
// refresh animelist of users
// TODO
animesUsers, err := ReadAnimeUsers()
if err != nil {
if err != nutsdb.ErrBucketEmpty {
color.Errorln(err.Error())
}
return
}
// iterate anime
for _, a := range animesUsers {
// iterate users
for _, u := range a.Users {
newProgress, updated, err := FetchProgress(a.Anime, u.MalID, u.Username, u.Progress)
if err != nil {
color.Errorln(err.Error())
continue
}
if newProgress == u.Progress {
continue
}
// update db
color.Infof("%s progress von %d: %d -> %d\n", u.Username, a.Anime, u.Progress, newProgress)
err = UpdateUserAnimeProgress(a.Anime, u.MalID, newProgress, updated)
if err != nil {
color.Errorln(err.Error())
}
}
}
}
func LangeArbeiten() {