Add appointment to watchext

This commit is contained in:
daru
2022-05-28 14:52:32 +02:00
parent 5b029ee835
commit 97f94e5e2f
3 changed files with 33 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ import (
"fmt"
"strings"
"time"
"github.com/xujiajun/nutsdb"
)
func JikanConvert(jik *SeasonAnimeJikan) Anime {
@@ -160,6 +162,24 @@ func SearchAnime(animeId int64) (*Anime, error) {
return anime, err
}
func SearchAppointments(animeId int64) ([]Appointment, error) {
appointments, err := ReadAppointments()
if err != nil {
if strings.Contains(err.Error(), "not found") || err == nutsdb.ErrBucketEmpty {
return make([]Appointment, 0), nil
} else {
return appointments, err
}
}
result := make([]Appointment, 0)
for _, a := range appointments {
if animeId == a.Anime {
result = append(result, a)
}
}
return result, nil
}
func FetchProgress(animeId, userId int64, username string, progress int) (int, time.Time, string, error) {
// check watching first
newProgress, updated, err := fetchProgressOnState(animeId, userId, progress, username, malApiStatusW)