Skip to content

Commit

Permalink
Merge pull request #29 from zumicts/master
Browse files Browse the repository at this point in the history
Fixes #30: Kiesza bug in parsing Album.Tags
  • Loading branch information
rikkit committed Oct 22, 2014
2 parents 150d50f + 07a5fab commit d0a4283
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/IF.Lastfm.Core/Objects/LastAlbum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ internal static LastAlbum ParseJToken(JToken token)
{
var tagToken = tagsToken.SelectToken("tag");
if (tagToken != null)
a.TopTags = tagToken.Children().Select(LastTag.ParseJToken);
{
a.TopTags =
tagToken.Type == JTokenType.Array
? tagToken.Children().Select(LastTag.ParseJToken)
: new List<LastTag> { LastTag.ParseJToken(tagToken) };
}
}

a.ListenerCount = token.Value<int>("listeners");
Expand Down
11 changes: 9 additions & 2 deletions src/IF.Lastfm.Core/Objects/LastArtist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ internal static LastArtist ParseJToken(JToken token)
a.OnTour = Convert.ToBoolean(token.Value<int>("ontour"));

var tagsToken = token.SelectToken("tags");
if (tagsToken != null && tagsToken.HasValues)
if (tagsToken != null)
{
a.Tags = tagsToken.SelectToken("tag").Children().Select(LastTag.ParseJToken);
var tagToken = tagsToken.SelectToken("tag");
if (tagToken != null)
{
a.Tags =
tagToken.Type == JTokenType.Array
? tagToken.Children().Select(LastTag.ParseJToken)
: new List<LastTag> { LastTag.ParseJToken(tagToken) };
}
}

var images = token.SelectToken("image");
Expand Down
11 changes: 9 additions & 2 deletions src/IF.Lastfm.Core/Objects/LastTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ internal static LastTrack ParseJToken(JToken token)
}

var tagsToken = token.SelectToken("toptags");
if (tagsToken != null && tagsToken.HasValues)
if (tagsToken != null)
{
t.TopTags = tagsToken.SelectToken("tag").Children().Select(LastTag.ParseJToken);
var tagToken = tagsToken.SelectToken("tag");
if (tagToken != null)
{
t.TopTags =
tagToken.Type == JTokenType.Array
? tagToken.Children().Select(LastTag.ParseJToken)
: new List<LastTag> { LastTag.ParseJToken(tagToken) };
}
}

var date = token.SelectToken("date");
Expand Down

0 comments on commit d0a4283

Please sign in to comment.