From 79c3ba2636a188697a6161d0d68b4ba8cdedc664 Mon Sep 17 00:00:00 2001 From: bytedream Date: Fri, 24 Jun 2022 11:51:48 +0200 Subject: [PATCH] Refactor to use consts instead of string --- search.go | 8 ++++---- suggestions.go | 4 ++-- video.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/search.go b/search.go index d7f6e76..cbbf7e9 100644 --- a/search.go +++ b/search.go @@ -61,7 +61,7 @@ func (c *Crunchyroll) Browse(options BrowseOptions, limit uint) (s []*Series, m for _, item := range jsonBody["items"].([]interface{}) { switch item.(map[string]interface{})["type"] { - case "series": + case MediaTypeSeries: series := &Series{ crunchy: c, } @@ -73,7 +73,7 @@ func (c *Crunchyroll) Browse(options BrowseOptions, limit uint) (s []*Series, m } s = append(s, series) - case "movie_listing": + case MediaTypeMovie: movie := &Movie{ crunchy: c, } @@ -160,7 +160,7 @@ func (c *Crunchyroll) Search(query string, limit uint) (s []*Series, m []*Movie, item := item.(map[string]interface{}) if item["total"].(float64) > 0 { switch item["type"] { - case "series": + case MediaTypeSeries: for _, series := range item["items"].([]interface{}) { series2 := &Series{ crunchy: c, @@ -174,7 +174,7 @@ func (c *Crunchyroll) Search(query string, limit uint) (s []*Series, m []*Movie, s = append(s, series2) } - case "movie_listing": + case MediaTypeMovie: for _, movie := range item["items"].([]interface{}) { movie2 := &Movie{ crunchy: c, diff --git a/suggestions.go b/suggestions.go index d6bd770..35d7a9b 100644 --- a/suggestions.go +++ b/suggestions.go @@ -23,7 +23,7 @@ func (c *Crunchyroll) Recommendations(limit uint) (s []*Series, m []*Movie, err for _, item := range jsonBody["items"].([]interface{}) { switch item.(map[string]interface{})["type"] { - case "series": + case MediaTypeSeries: series := &Series{ crunchy: c, } @@ -35,7 +35,7 @@ func (c *Crunchyroll) Recommendations(limit uint) (s []*Series, m []*Movie, err } s = append(s, series) - case "movie_listing": + case MediaTypeMovie: movie := &Movie{ crunchy: c, } diff --git a/video.go b/video.go index 2d76499..04ea5e9 100644 --- a/video.go +++ b/video.go @@ -223,7 +223,7 @@ func (s *Series) Similar(limit uint) (ss []*Series, m []*Movie, err error) { for _, item := range jsonBody["items"].([]interface{}) { switch item.(map[string]interface{})["type"] { - case "series": + case MediaTypeSeries: series := &Series{ crunchy: s.crunchy, } @@ -235,7 +235,7 @@ func (s *Series) Similar(limit uint) (ss []*Series, m []*Movie, err error) { } ss = append(ss, series) - case "movie_listing": + case MediaTypeMovie: movie := &Movie{ crunchy: s.crunchy, }