Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
Fixes XPath Exception when no music in the timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
PoLaKoSz committed Dec 15, 2018
1 parent 5435711 commit c74c490
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
<PackageId>MusicFM.hu</PackageId>
<Product>MusicFM.hu</Product>
<NeutralLanguage>en</NeutralLanguage>
<PackageReleaseNotes>First stable release. The enty point to the library is the MusicFM class. NuGet package now contains the XML documentation.</PackageReleaseNotes>
<PackageReleaseNotes>Fixes "Couldn't find songs with the given XPath!" Exception when the timeline tracklist is 0.</PackageReleaseNotes>
<Description>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).</Description>
<Version>1.0.1.1</Version>
<Version>1.0.2</Version>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<FileVersion>1.0.2.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 3 additions & 0 deletions src/Parsers/TimelineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ internal static class TimelineParser
/// <exception cref="NodeNotFoundException"></exception>
internal static List<Track> Process(string json, ICleaner clean)
{
if (json.StartsWith("{\"count\":0,"))
return new List<Track>();

// If this not here, HtmlAgilityPack can't work
json = UnicodeCharactersToASCII(json).Replace(@"\/", "/");

Expand Down
19 changes: 19 additions & 0 deletions tests/Integration/EndPoints/HomePage/TimeLine/EmptyTimeline.cs
Original file line number Diff line number Diff line change
@@ -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<Track> _raw = new List<Track>();
private static readonly List<Track> _cleaned = new List<Track>();



public EmptyTimeline()
: base(_raw, _cleaned)
{
base.SetResponseFromServer(@"HomePage\timeline.json");
}
}
}
3 changes: 3 additions & 0 deletions tests/Integration/Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<None Update="StaticResources\Charts\50\all.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="StaticResources\HomePage\timeline.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="StaticResources\MusicKillers\antonyo.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/StaticResources/HomePage/timeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"count":0,"items":[""],"first":0}

0 comments on commit c74c490

Please sign in to comment.