diff --git a/src/Library.csproj b/src/Library.csproj index a12237b..e2eda0d 100644 --- a/src/Library.csproj +++ b/src/Library.csproj @@ -13,9 +13,11 @@ MusicFM.hu MusicFM.hu en - First stable release. The enty point to the library is the MusicFM class. NuGet package now contains the XML documentation. + Fixes "Couldn't find songs with the given XPath!" Exception when the timeline tracklist is 0. MusicFM.hu is the one of the most popular radio station in Hungary. This is a .NET Standard 2.0 library to can access the Timeline, every MusicKIller DJ's tracklist and the two chart (TOP 20 and TOP 50). - 1.0.1.1 + 1.0.2 + 1.0.2.0 + 1.0.2.0 diff --git a/src/Parsers/TimelineParser.cs b/src/Parsers/TimelineParser.cs index dd6379e..0f3aa3d 100644 --- a/src/Parsers/TimelineParser.cs +++ b/src/Parsers/TimelineParser.cs @@ -17,6 +17,9 @@ internal static class TimelineParser /// internal static List Process(string json, ICleaner clean) { + if (json.StartsWith("{\"count\":0,")) + return new List(); + // If this not here, HtmlAgilityPack can't work json = UnicodeCharactersToASCII(json).Replace(@"\/", "/"); diff --git a/tests/Integration/EndPoints/HomePage/TimeLine/EmptyTimeline.cs b/tests/Integration/EndPoints/HomePage/TimeLine/EmptyTimeline.cs new file mode 100644 index 0000000..a94fdb3 --- /dev/null +++ b/tests/Integration/EndPoints/HomePage/TimeLine/EmptyTimeline.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using PoLaKoSz.MusicFM.Models; + +namespace PoLaKoSz.MusicFM.Tests.Integration.EndPoints.HomePage.TimeLine +{ + class EmptyTimeline : TimeLineBase + { + private static readonly List _raw = new List(); + private static readonly List _cleaned = new List(); + + + + public EmptyTimeline() + : base(_raw, _cleaned) + { + base.SetResponseFromServer(@"HomePage\timeline.json"); + } + } +} diff --git a/tests/Integration/Integration.csproj b/tests/Integration/Integration.csproj index 4452e13..21832bc 100644 --- a/tests/Integration/Integration.csproj +++ b/tests/Integration/Integration.csproj @@ -27,6 +27,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/tests/Integration/StaticResources/HomePage/timeline.json b/tests/Integration/StaticResources/HomePage/timeline.json new file mode 100644 index 0000000..e0df39b --- /dev/null +++ b/tests/Integration/StaticResources/HomePage/timeline.json @@ -0,0 +1 @@ +{"count":0,"items":[""],"first":0}