32 lines
741 B
Go
32 lines
741 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"git.milar.in/milarin/anilist"
|
|
"git.milar.in/milarin/slices"
|
|
)
|
|
|
|
var AllMediaListStatuses = []anilist.MediaListStatus{
|
|
anilist.MediaListStatusCurrent,
|
|
anilist.MediaListStatusPlanning,
|
|
anilist.MediaListStatusCompleted,
|
|
anilist.MediaListStatusDropped,
|
|
anilist.MediaListStatusPaused,
|
|
anilist.MediaListStatusRepeating,
|
|
}
|
|
|
|
func ParseMediaListStatus(str string) (anilist.MediaListStatus, error) {
|
|
s := anilist.MediaListStatus(str)
|
|
|
|
allStatusesStr := slices.Map(AllMediaListStatuses, func(status anilist.MediaListStatus) string {
|
|
return string(status)
|
|
})
|
|
|
|
if !slices.Contains(AllMediaListStatuses, s) {
|
|
return s, ErrInvalidAnimeStatus.New(s, strings.Join(allStatusesStr, ","))
|
|
}
|
|
|
|
return s, nil
|
|
}
|