Add crunchylists endpoint

This commit is contained in:
bytedream 2022-06-19 01:56:39 +02:00
parent aa088cb318
commit 72484c78af
2 changed files with 167 additions and 0 deletions

View file

@ -893,6 +893,25 @@ func (c *Crunchyroll) Watchlist(options WatchlistOptions, limit uint) ([]*Watchl
return watchlistEntries, nil
}
func (c *Crunchyroll) CrunchyLists() (*CrunchyLists, error) {
endpoint := fmt.Sprintf("https://beta.crunchyroll.com/content/v1/custom-lists/%s?locale=%s", c.Config.AccountID, c.Locale)
resp, err := c.request(endpoint, http.MethodGet)
if err != nil {
return nil, err
}
defer resp.Body.Close()
crunchyLists := &CrunchyLists{
crunchy: c,
}
json.NewDecoder(resp.Body).Decode(crunchyLists)
for _, item := range crunchyLists.Items {
item.crunchy = c
}
return crunchyLists, nil
}
// Account returns information about the currently logged in crunchyroll account.
func (c *Crunchyroll) Account() (*Account, error) {
resp, err := c.request("https://beta.crunchyroll.com/accounts/v1/me", http.MethodGet)