Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in getting list of AudioFeatures for multiple trackIds #45

Closed
rakeshparveen5 opened this issue Apr 21, 2020 · 4 comments
Closed
Labels

Comments

@rakeshparveen5
Copy link

rakeshparveen5 commented Apr 21, 2020

When I try to get the audioFeature for single trackId , it works fine.
This code returns correct result and works fine:
var trackFeatures = await spotifyApi.audioFeatures.get("Single 1 spotify id");

But if I try to get list of audioFeatures for multiple trackIds I am getting exception using below code:
List ids = ["track id 1 from Spotify", "track id 2 from Spotify" ];
var trackFeatures = await spotifyApi.audioFeatures.list(ids);

This is the stacktrace :

Screenshot 2020-04-21 at 8 27 33 PM

The error is here in audio_features.dart

 Future<Iterable<AudioFeature>> list(Iterable<String> trackIds) async {
    var jsonString = await _api._get('$_path?ids=${trackIds.join(',')}');
    var map = json.decode(jsonString);

var artistsMap = map['audio-features'] as Iterable<dynamic>;     ----< map is null >---
return artistsMap.map((m) => AudioFeature.fromJson(m));

}

@rakeshparveen5
Copy link
Author

@rinukkusu As I checked the Spotify Api to get audioFeatures for multiple tracksIds, I found that the response returned by this api

"https://api.spotify.com/v1/audio-features?ids=6tLEIITb7OlqJ5rdAN77xq%2C4e3ZhgKuJz0xBmLbT6j9Pd%2C2c6a5RlXAB4Ab8Tm06n4eZ"

returns json with different key

{
"audio_features": [
{
"danceability": 0.591,
"energy": 0.922,

In the library's audio_features.dart , this function

Future<Iterable> list(Iterable trackIds)

having this line

var artistsMap = map['audio-features'] as Iterable<dynamic>;    

So, If we update the key as per api response , its working as expected and providing the correct result.

'audio-features' should be 'audio_features',

--

@rinukkusu
Copy link
Owner

Hi @rakeshparveen5 - thanks for finding this bug - care to create a PR?

@rinukkusu rinukkusu added the bug label Apr 21, 2020
@rinukkusu rinukkusu reopened this Apr 21, 2020
@rakeshparveen5
Copy link
Author

ok. @rinukkusu I will create a PR 👍

@rinukkusu
Copy link
Owner

Your fix is published in 0.3.1+1 - thanks for helping out! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants