mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
Fix bug with parsing tracks
sometimes they don't come with duration. so parse as string, which can be null, and then if is not null we try to parse it as a double
This commit is contained in:
parent
0b48051ce9
commit
c8612f8510
@ -88,7 +88,6 @@ internal static LastTrack ParseJToken(JToken token)
|
||||
{
|
||||
t.IsLoved = Convert.ToBoolean(lovedToken.Value<int>());
|
||||
}
|
||||
|
||||
var attrToken = token.SelectToken("@attr");
|
||||
if (attrToken != null && attrToken.HasValues)
|
||||
{
|
||||
@ -97,10 +96,15 @@ internal static LastTrack ParseJToken(JToken token)
|
||||
}
|
||||
|
||||
// api returns milliseconds when track.getInfo is called directly
|
||||
var secs = token.Value<double>("duration");
|
||||
if (Math.Abs(secs - default(double)) > double.Epsilon)
|
||||
var secsStr = token.Value<string>("duration");
|
||||
double secs;
|
||||
|
||||
if (double.TryParse(secsStr, out secs))
|
||||
{
|
||||
t.Duration = TimeSpan.FromMilliseconds(secs);
|
||||
if (Math.Abs(secs - default(double)) > double.Epsilon)
|
||||
{
|
||||
t.Duration = TimeSpan.FromMilliseconds(secs);
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
|
Loading…
Reference in New Issue
Block a user