diff --git a/SynologyDotNet.AudioStation.IntegrationTest/AudioStationConnector_Tests.cs b/SynologyDotNet.AudioStation.IntegrationTest/AudioStationConnector_Tests.cs index 692f84e..084c0e4 100644 --- a/SynologyDotNet.AudioStation.IntegrationTest/AudioStationConnector_Tests.cs +++ b/SynologyDotNet.AudioStation.IntegrationTest/AudioStationConnector_Tests.cs @@ -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] @@ -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] diff --git a/SynologyDotNet.AudioStation.IntegrationTest/SynologyDotNet.AudioStation.IntegrationTest.csproj b/SynologyDotNet.AudioStation.IntegrationTest/SynologyDotNet.AudioStation.IntegrationTest.csproj index 9b697a7..6106aa7 100644 --- a/SynologyDotNet.AudioStation.IntegrationTest/SynologyDotNet.AudioStation.IntegrationTest.csproj +++ b/SynologyDotNet.AudioStation.IntegrationTest/SynologyDotNet.AudioStation.IntegrationTest.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/SynologyDotNet.AudioStation/AudioStationClient.cs b/SynologyDotNet.AudioStation/AudioStationClient.cs index a3c86b9..854e4ff 100644 --- a/SynologyDotNet.AudioStation/AudioStationClient.cs +++ b/SynologyDotNet.AudioStation/AudioStationClient.cs @@ -91,7 +91,7 @@ public async Task> ListArtistsAsync(int limit, int /// public async Task 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; } @@ -124,7 +124,7 @@ public async Task> ListAlbumsAsync(int limit, int of /// public async Task 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; @@ -167,7 +167,7 @@ public async Task> 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>(SYNO_AudioStation_Song, "getinfo", args.ToArray()); + var result = await Client.QueryObjectAsync>(SYNO_AudioStation_Song, "getinfo", args.ToArray()); return result; } @@ -181,7 +181,7 @@ public async Task RateSongAsync(string songId, int rating) { if (rating < 0 || rating > 5) throw new ArgumentOutOfRangeException(nameof(rating), "Value range: 0 - 5"); - var result = await Client.QueryAsync(SYNO_AudioStation_Song, "setrating", + var result = await Client.QueryObjectAsync(SYNO_AudioStation_Song, "setrating", ("id", songId), ("rating", rating)); return result; @@ -304,13 +304,18 @@ public async Task SetSongFileTags(FileTagChange change) } #endregion - #region Search + #region Search + /// + /// Searches the music library. + /// + /// The text to search. + /// public async Task> 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>(SYNO_AudioStation_Search, "list", args.ToArray()); + var result = await Client.QueryObjectAsync>(SYNO_AudioStation_Search, "list", args.ToArray()); return result; } #endregion diff --git a/SynologyDotNet.AudioStation/Model/SearchResults.cs b/SynologyDotNet.AudioStation/Model/SearchResults.cs index c4c3c26..cfecabe 100644 --- a/SynologyDotNet.AudioStation/Model/SearchResults.cs +++ b/SynologyDotNet.AudioStation/Model/SearchResults.cs @@ -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; } } diff --git a/SynologyDotNet.AudioStation/SynologyDotNet.AudioStation.csproj b/SynologyDotNet.AudioStation/SynologyDotNet.AudioStation.csproj index 0baf8ce..6d63904 100644 --- a/SynologyDotNet.AudioStation/SynologyDotNet.AudioStation.csproj +++ b/SynologyDotNet.AudioStation/SynologyDotNet.AudioStation.csproj @@ -8,7 +8,7 @@ SynologyDotNet.AudioStation - 0.3.0 + 0.4.0 SynologyDotNet.AudioStation https://github.com/geloczigeri/synologydotnet-audiostation Gergő Gelóczi @@ -58,7 +58,7 @@ - +