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

Error fetching playlists #69

Open
stefanoromanello opened this issue Jul 23, 2020 · 1 comment
Open

Error fetching playlists #69

stefanoromanello opened this issue Jul 23, 2020 · 1 comment

Comments

@stefanoromanello
Copy link
Contributor

stefanoromanello commented Jul 23, 2020

I'm testing my code with 70+ playlists and in some of them when I try to get the tracks by using getTracksByPlaylistId I get a broken list (Iterable) see https://i.imgur.com/T3Tyt38.png. It seems that it starts to put some tracks but can't finish the list.

I've done some debug in the sdk code and when the code is parsing each song of the playlist in the method "Track _$TrackFromJson(Map<String, dynamic> json)" present in _models.g.dart at some point for one song of the playlist the parameter json is null.

And when I try to read the length of the Iterable returned by getTracksByPlaylistId I get:

Exception has occurred. NoSuchMethodError (NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: []("album"))

but the song that get a null json object has an album and it is not a podcast in the playlist.

Ps: this occurs with 4/5 playlists over the 70+

Update: the getPage method works correctly for every page and the problem seems to be in this pages.expand:

  Future<Iterable<T>> all([int limit = defaultLimit]) {
 
    return stream(limit)
        .map((page) => page.items)
        .toList()
        .then((pages) {
          Iterable<T> all = pages.expand((page) => page);
          return all;
        } );
  }

which returns a broken iterable

Also, for avoiding the api rate limit is there a quicker way to get all the songs of all playlist or the only way is to fetch each playlist and use getTracksByPlaylistId?

@stefanoromanello
Copy link
Contributor Author

The problem is in the spotify's api. Some playlists returns the "count" field with more songs than in the actual response.

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

No branches or pull requests

2 participants