Change watchlist option order type and content type

This commit is contained in:
bytedream 2022-06-23 17:16:47 +02:00
parent 14491ce6c9
commit e6172cdf90

View file

@ -16,18 +16,17 @@ const (
WatchlistLanguageDubbed WatchlistLanguageDubbed
) )
// WatchlistContentType represents a filter type to filter Crunchyroll.Watchlist entries if they're series or movies. type WatchlistOrderType string
type WatchlistContentType string
const ( const (
WatchlistContentSeries WatchlistContentType = "series" WatchlistOrderAsc = "asc"
WatchlistContentMovies = "movie_listing" WatchlistOrderDesc = "desc"
) )
// WatchlistOptions represents options for receiving the user watchlist. // WatchlistOptions represents options for receiving the user watchlist.
type WatchlistOptions struct { type WatchlistOptions struct {
// OrderAsc specified whether the results should be order ascending or descending. // Order specified whether the results should be order ascending or descending.
OrderAsc bool Order WatchlistOrderType
// OnlyFavorites specifies whether only episodes which are marked as favorite should be returned. // OnlyFavorites specifies whether only episodes which are marked as favorite should be returned.
OnlyFavorites bool OnlyFavorites bool
@ -38,17 +37,16 @@ type WatchlistOptions struct {
// ContentType specified whether returning videos should only be series episodes or movies. // ContentType specified whether returning videos should only be series episodes or movies.
// But tbh all movies I've searched on crunchy were flagged as series too, so this // But tbh all movies I've searched on crunchy were flagged as series too, so this
// parameter is kinda useless. // parameter is kinda useless.
ContentType WatchlistContentType ContentType MediaType
} }
// Watchlist returns the watchlist entries for the currently logged in user. // Watchlist returns the watchlist entries for the currently logged in user.
func (c *Crunchyroll) Watchlist(options WatchlistOptions, limit uint) ([]*WatchlistEntry, error) { func (c *Crunchyroll) Watchlist(options WatchlistOptions, limit uint) ([]*WatchlistEntry, error) {
values := url.Values{} values := url.Values{}
if options.OrderAsc { if options.Order == "" {
values.Set("order", "asc") options.Order = WatchlistOrderDesc
} else {
values.Set("order", "desc")
} }
values.Set("order", string(options.Order))
if options.OnlyFavorites { if options.OnlyFavorites {
values.Set("only_favorites", "true") values.Set("only_favorites", "true")
} }