From 8b4651fad4a747c47d3eb0d57c995168f0ccc9a1 Mon Sep 17 00:00:00 2001 From: milarin Date: Mon, 16 Jan 2023 15:04:56 +0100 Subject: [PATCH] added GetCurrentlyWatchingAnimesContext --- anilist.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/anilist.go b/anilist.go index 093983e..09b1d9f 100644 --- a/anilist.go +++ b/anilist.go @@ -19,13 +19,17 @@ func GetAnimeListByAnimeID() (map[anilist.MediaID]*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() if err != nil { return nil, ErrAnimeListNotObtainable.Wrap(err, "access token acquisition failed") } 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, Type: anilist.MediaTypeAnime, Status: status,