zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.38k stars 292 forks source link

client.Search for SearchTypeShow returns zero values #257

Open Santiago-Balcero opened 6 months ago

Santiago-Balcero commented 6 months ago

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!

subash774 commented 5 months ago

@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.

Santiago-Balcero commented 5 months ago

@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 commented 5 months ago

Created PR to fix this: PR #258