This project is read-only.

Fails to read some playlists

Jan 7, 2015 at 2:55 PM
First thanks for a great and lightweight library. I like the condensed and simple api you've written.

I'm successfully fetching public user playlists, but in some cases it fails.

For example I can't read this list from Spotify http://open.spotify.com/user/1111616570/playlist/25pK0gGKsfBoGbntD2luzK with the SpotifyWebAPI.Playlist.GetPlaylist(userId, playlistId, authToken); method.

And if you run the request here it succeeds: https://developer.spotify.com/web-api/console/get-playlist/?playlist_id=25pK0gGKsfBoGbntD2luzK&user_id=1111616570

Do you have any ideas?

Thanks in advance,
Olle
Coordinator
Jan 7, 2015 at 3:30 PM
Hi ollebulle,

Thanks for your interest in the project. My initial thought is that the playlist model has changed and the conversion between the retrieved JSON object no longer matches the model I created in the library.

I'm at work right now but I may be able to take a look tonight.

Cheers!

tinyioda
Jan 21, 2015 at 7:29 PM
I only have GIT installed right now but here are the fix:
(Null check on added_by)

Thanks!

namespace SpotifyWebAPI.SpotifyModel
{
[JsonObject]
internal class playlisttrack
{
    public string added_at { get; set; }
    public user added_by { get; set; }
    public track track { get; set; }

    public PlaylistTrack ToPOCO()
    {
        PlaylistTrack pt = new PlaylistTrack();
        DateTime addedAt;
        if (DateTime.TryParse(this.added_at, out addedAt))
            pt.AddedAt = addedAt;
        else
            pt.AddedAt = DateTime.Now;
    if(this.added_by != null)
    pt.AddedBy = this.added_by.ToPOCO();
        pt.Track = this.track.ToPOCO();

        return pt;
    }
}
}
}
Coordinator
Feb 2, 2015 at 7:29 PM
I've committed your change! thanks for supporting the project!