accept statuses on media list queries
This commit is contained in:
parent
433adc9752
commit
6cf36a2e55
@ -18,17 +18,17 @@ func GetAnimeListByAnimeID() (map[anilist.MediaID]*anilist.MediaList, error) {
|
|||||||
return channel.ToMap(watchingAnimesChannel, toMapFunc), nil
|
return channel.ToMap(watchingAnimesChannel, toMapFunc), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCurrentlyWatchingAnimes() (<-chan *anilist.MediaList, error) {
|
func GetCurrentlyWatchingAnimes(statuses ...anilist.MediaListStatus) (<-chan *anilist.MediaList, error) {
|
||||||
return GetCurrentlyWatchingAnimesContext(context.Background())
|
return GetCurrentlyWatchingAnimesContext(context.Background(), statuses...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCurrentlyWatchingAnimesContext(ctx context.Context) (<-chan *anilist.MediaList, error) {
|
func GetCurrentlyWatchingAnimesContext(ctx context.Context, statuses ...anilist.MediaListStatus) (<-chan *anilist.MediaList, error) {
|
||||||
token, err := GetAnilistAccessToken()
|
token, err := GetAnilistAccessToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrAnimeListNotObtainable.Wrap(err, "access token acquisition failed")
|
return nil, ErrAnimeListNotObtainable.Wrap(err, "access token acquisition failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
media := channel.Map(channel.Of(AnimeStatuses...), func(status anilist.MediaListStatus) <-chan *anilist.MediaList {
|
media := channel.Map(channel.Of(statuses...), func(status anilist.MediaListStatus) <-chan *anilist.MediaList {
|
||||||
return anilist.NewApi(token).GetMediaList(ctx, anilist.MediaListQuery{
|
return anilist.NewApi(token).GetMediaList(ctx, anilist.MediaListQuery{
|
||||||
UserName: AnilistUsername,
|
UserName: AnilistUsername,
|
||||||
Type: anilist.MediaTypeAnime,
|
Type: anilist.MediaTypeAnime,
|
||||||
|
Loading…
Reference in New Issue
Block a user