spotify icon indicating copy to clipboard operation
spotify copied to clipboard

client.Search for SearchTypeShow returns zero values

Open Santiago-Balcero opened this issue 1 year ago • 3 comments

Hi!

Currently working in a project with this Spotify client. When using client.Search for SearchTypeShow it always returns zero values of type SimpleShowPage.

I create client in this way:

ctx := context.Background()
	authConfig := &clientcredentials.Config{
		ClientID:     SpotifyId,
		ClientSecret: SpotifySecret,
		TokenURL:     spotifyauth.TokenURL,
	}

	accessToken, err := authConfig.Token(ctx)
	if err != nil {
		log.Fatal("Error creating spotify client: ", err)
	}
	httpClient := spotifyauth.New().Client(ctx, accessToken)
	Spotify = *spotify.New(httpClient)

This is the line I use to call the search method, being podcastName a string:

result, err := client.Search(ctx, podcastName, spotify.SearchTypeShow)
if err != nil {
	return "", fmt.Errorf("error searching podcast: %v", err)
}

log.Println(result.Shows)

And this is what I get as result.Shows no matter which podcastName value I use:

2024/03/28 20:54:39 &{{https://api.spotify.com/v1/search?query=cosas+de+profes&type=show&offset=0&limit=20 20 0 399 https://api.spotify.com/v1/search?query=cosas+de+profes&type=show&offset=20&limit=20 } [{{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}} {{[] []  false map[]   [] <nil> []     } {{ 0 0 0  } []}}]}

I am using the exact same way to search for SearchTypeArtist, which works perfectly.

Any help or comments would be helpful. Thanks!

Santiago-Balcero avatar Mar 29 '24 02:03 Santiago-Balcero

@Santiago-Balcero result.Shows is of type SimpleShowPage, you'll find your actual shows inside that object, so result.Shows.Shows should give you what you're looking for.

subash774 avatar Apr 08 '24 19:04 subash774

@subash774 You are right, it should. But when looking into results.Shows.Shows I see nothing. Following line prints nothing.

for _, a := range result.Shows.Shows {
        log.Println(a)
}

Santiago-Balcero avatar Apr 12 '24 00:04 Santiago-Balcero

Created PR to fix this: PR #258

Santiago-Balcero avatar Apr 14 '24 19:04 Santiago-Balcero