Skip to content

Commit

Permalink
Search artists by keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
geloczi committed Dec 20, 2021
1 parent d33badc commit cd32c5d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,22 @@ public async Task Search()
Assert.IsTrue(response.Data.SongTotal > 0);
}

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

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

[TestMethod]
public async Task Playlist_List()
{
Expand Down
18 changes: 17 additions & 1 deletion SynologyDotNet.AudioStation/AudioStationClient.Artist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,30 @@ public async Task<ApiListRessponse<ArtistList>> ListArtistsAsync(int limit, int
/// <param name="offset">Start position in the list (use it for paging)</param>
/// <param name="genre">Filter by genre</param>
/// <returns></returns>
public async Task<ApiListRessponse<ArtistList>> ListArtistsAsync(int limit, int offset, string genre)
public async Task<ApiListRessponse<ArtistList>> SearchArtistsByGenreAsync(int limit, int offset, string genre)
{
return await Client.QueryListAsync<ApiListRessponse<ArtistList>>(SYNO_AudioStation_Artist, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"),
("genre", genre));
}

/// <summary>
/// List artists
/// </summary>
/// <param name="limit">Maximum number of items to return</param>
/// <param name="offset">Start position in the list (use it for paging)</param>
/// <param name="keyword">Filter by keyword</param>
/// <returns></returns>
public async Task<ApiListRessponse<ArtistList>> SearchArtistsByNameAsync(int limit, int offset, string keyword)
{
return await Client.QueryListAsync<ApiListRessponse<ArtistList>>(SYNO_AudioStation_Artist, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"),
("keyword", keyword),
("filter", keyword));
}

/// <summary>
/// Download artist cover image
/// </summary>
Expand Down

0 comments on commit cd32c5d

Please sign in to comment.