Skip to content

Commit

Permalink
Search genres by keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
geloczi committed Dec 20, 2021
1 parent e970db6 commit 018360c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ public async Task SearchComposersByName()
Assert.IsTrue(response.Data.Composers.Any(x => x.Name.Contains(TestSong.Additional.Tag.Composer, StringComparison.OrdinalIgnoreCase)));
}

[TestMethod]
public async Task SearchGenresByNameAsync()
{
var response = await AudioStation.SearchGenresByNameAsync(TestPageSize, 0, TestSong.Additional.Tag.Genre);
Assert.IsTrue(response.Success);
Assert.IsTrue(response.Data.Genres.Any(x => x.Name.Contains(TestSong.Additional.Tag.Genre, StringComparison.OrdinalIgnoreCase)));
}

[TestMethod]
public async Task Playlist_List()
{
Expand Down
25 changes: 23 additions & 2 deletions SynologyDotNet.AudioStation/AudioStationClient.Genre.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using SynologyDotNet.AudioStation.Model;
using SynologyDotNet.Core.Responses;

namespace SynologyDotNet.AudioStation
{
public partial class AudioStationClient
{
/// <summary>
/// Lists the genres.
/// </summary>
/// <param name="limit">The limit.</param>
/// <param name="offset">The offset.</param>
/// <returns></returns>
public async Task<ApiListRessponse<GenreList>> ListGenresAsync(int limit, int offset)
{
return await Client.QueryListAsync<ApiListRessponse<GenreList>>(SYNO_AudioStation_Genre, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"));
}

/// <summary>
/// Searches the genres by name.
/// </summary>
/// <param name="limit">The limit.</param>
/// <param name="offset">The offset.</param>
/// <param name="keyword">The keyword.</param>
/// <returns></returns>
public async Task<ApiListRessponse<GenreList>> SearchGenresByNameAsync(int limit, int offset, string keyword)
{
return await Client.QueryListAsync<ApiListRessponse<GenreList>>(SYNO_AudioStation_Genre, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"),
("keyword", keyword),
("filter", keyword));
}
}
}

0 comments on commit 018360c

Please sign in to comment.