added GetCurrentlyWatchingAnimesContext
This commit is contained in:
parent
d266f73152
commit
8b4651fad4
@ -19,13 +19,17 @@ func GetAnimeListByAnimeID() (map[anilist.MediaID]*anilist.MediaList, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetCurrentlyWatchingAnimes() (<-chan *anilist.MediaList, error) {
|
func GetCurrentlyWatchingAnimes() (<-chan *anilist.MediaList, error) {
|
||||||
|
return GetCurrentlyWatchingAnimesContext(context.Background())
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetCurrentlyWatchingAnimesContext(ctx context.Context) (<-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(AnimeStatuses...), func(status anilist.MediaListStatus) <-chan *anilist.MediaList {
|
||||||
return anilist.NewApi(token).GetMediaList(context.Background(), anilist.MediaListQuery{
|
return anilist.NewApi(token).GetMediaList(ctx, anilist.MediaListQuery{
|
||||||
UserName: AnilistUsername,
|
UserName: AnilistUsername,
|
||||||
Type: anilist.MediaTypeAnime,
|
Type: anilist.MediaTypeAnime,
|
||||||
Status: status,
|
Status: status,
|
||||||
|
Loading…
Reference in New Issue
Block a user