Skip to content

Commit

Permalink
Update nuget packages
Browse files Browse the repository at this point in the history
  • Loading branch information
geloczi committed Dec 19, 2021
1 parent 9822bb3 commit e95ec02
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,19 @@ public async Task GetArtistCover()
[TestMethod]
public async Task GetArtistCover_NotFound()
{
var response = await AudioStation.GetArtistCoverAsync("This artist does not even exist 123456789");
Assert.IsTrue(response is null);
Exception exception = null;
try
{
var response = await AudioStation.GetArtistCoverAsync("This artist does not even exist 123456789");
}
catch (Exception ex)
{
exception = ex;
}
Assert.IsNotNull(exception);
Assert.IsInstanceOfType(exception, typeof(SynologyDotNet.Core.Exceptions.SynoHttpException));
var synoHttpException = (SynologyDotNet.Core.Exceptions.SynoHttpException)exception;
Assert.AreEqual(System.Net.HttpStatusCode.NotFound, synoHttpException.StatusCode);
}

[TestMethod]
Expand All @@ -248,8 +259,19 @@ public async Task GetAlbumCover()
[TestMethod]
public async Task GetAlbumCover_NotFound()
{
var response = await AudioStation.GetAlbumCoverAsync("This artist does not even exist 123456789", "This album does not even exist 123456789");
Assert.IsTrue(response is null);
Exception exception = null;
try
{
var response = await AudioStation.GetAlbumCoverAsync("This artist does not even exist 123456789", "This album does not even exist 123456789");
}
catch (Exception ex)
{
exception = ex;
}
Assert.IsNotNull(exception);
Assert.IsInstanceOfType(exception, typeof(SynologyDotNet.Core.Exceptions.SynoHttpException));
var synoHttpException = (SynologyDotNet.Core.Exceptions.SynoHttpException)exception;
Assert.AreEqual(System.Net.HttpStatusCode.NotFound, synoHttpException.StatusCode);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

Expand Down
17 changes: 11 additions & 6 deletions SynologyDotNet.AudioStation/AudioStationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task<ApiListRessponse<ArtistList>> ListArtistsAsync(int limit, int
/// <returns></returns>
public async Task<ByteArrayData> GetArtistCoverAsync(string artist)
{
var result = await Client.QueryImageAsync(SYNO_AudioStation_Cover, "getcover", true,
var result = await Client.QueryByteArrayAsync(SYNO_AudioStation_Cover, "getcover",
("artist_name", artist));
return result;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public async Task<ApiListRessponse<AlbumList>> ListAlbumsAsync(int limit, int of
/// <returns></returns>
public async Task<ByteArrayData> GetAlbumCoverAsync(string artist, string album)
{
var result = await Client.QueryImageAsync(SYNO_AudioStation_Cover, "getcover", true,
var result = await Client.QueryByteArrayAsync(SYNO_AudioStation_Cover, "getcover",
("album_name", album),
("album_artist_name", artist));
return result;
Expand Down Expand Up @@ -167,7 +167,7 @@ public async Task<ApiListRessponse<SongList>> GetSongByIdAsync(string id)
var args = new List<(string, object)>();
args.Add(("id", id));
args.Add(("additional", "song_tag, song_audio, song_rating")); // request detailed song info
var result = await Client.QueryAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "getinfo", args.ToArray());
var result = await Client.QueryObjectAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "getinfo", args.ToArray());
return result;
}

Expand All @@ -181,7 +181,7 @@ public async Task<ApiResponse> RateSongAsync(string songId, int rating)
{
if (rating < 0 || rating > 5)
throw new ArgumentOutOfRangeException(nameof(rating), "Value range: 0 - 5");
var result = await Client.QueryAsync<ApiResponse>(SYNO_AudioStation_Song, "setrating",
var result = await Client.QueryObjectAsync<ApiResponse>(SYNO_AudioStation_Song, "setrating",
("id", songId),
("rating", rating));
return result;
Expand Down Expand Up @@ -304,13 +304,18 @@ public async Task<ApiResponse> SetSongFileTags(FileTagChange change)
}
#endregion

#region Search
#region Search
/// <summary>
/// Searches the music library.
/// </summary>
/// <param name="keyword">The text to search.</param>
/// <returns></returns>
public async Task<ApiDataResponse<SearchResults>> SearchAsync(string keyword)
{
var args = new List<(string, object)>();
args.Add(("additional", "song_tag, song_audio, song_rating")); // request detailed song info
args.Add(("keyword", keyword));
var result = await Client.QueryAsync<ApiDataResponse<SearchResults>>(SYNO_AudioStation_Search, "list", args.ToArray());
var result = await Client.QueryObjectAsync<ApiDataResponse<SearchResults>>(SYNO_AudioStation_Search, "list", args.ToArray());
return result;
}
#endregion
Expand Down
5 changes: 5 additions & 0 deletions SynologyDotNet.AudioStation/Model/SearchResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ public class SearchResults
{
[JsonProperty("albumTotal")]
public int AlbumTotal { get; set; }

[JsonProperty("albums")]
public Album[] Albums { get; set; }

[JsonProperty("artistTotal")]
public int ArtistTotal { get; set; }

[JsonProperty("artists")]
public Artist[] Artists { get; set; }

[JsonProperty("songTotal")]
public int SongTotal { get; set; }

[JsonProperty("songs")]
public Song[] Songs { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- General -->
<PropertyGroup>
<Product>SynologyDotNet.AudioStation</Product>
<Version>0.3.0</Version>
<Version>0.4.0</Version>
<Description>SynologyDotNet.AudioStation</Description>
<RepositoryUrl>https://github.com/geloczigeri/synologydotnet-audiostation</RepositoryUrl>
<Authors>Gergő Gelóczi</Authors>
Expand Down Expand Up @@ -58,7 +58,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="SynologyDotNet.Core" Version="0.3.0" />
<PackageReference Include="SynologyDotNet.Core" Version="0.4.0" />
</ItemGroup>
</Otherwise>
</Choose>
Expand Down

0 comments on commit e95ec02

Please sign in to comment.