handle json unmarshall error

This commit is contained in:
Hekmon 2022-04-29 11:45:00 +02:00
parent 187a0c8817
commit 362708cf35
No known key found for this signature in database
GPG key ID: 8C27AA76AB6EFF96

View file

@ -295,7 +295,9 @@ func (c *Crunchyroll) Search(query string, limit uint) (s []*Series, m []*Movie,
defer resp.Body.Close() defer resp.Body.Close()
var jsonBody map[string]interface{} var jsonBody map[string]interface{}
json.NewDecoder(resp.Body).Decode(&jsonBody) if err = json.NewDecoder(resp.Body).Decode(&jsonBody); err != nil {
return nil, nil, fmt.Errorf("failed to parse 'search' response: %w", err)
}
for _, item := range jsonBody["items"].([]interface{}) { for _, item := range jsonBody["items"].([]interface{}) {
item := item.(map[string]interface{}) item := item.(map[string]interface{})