Skip to content

Commit

Permalink
Indexing service support
Browse files Browse the repository at this point in the history
  • Loading branch information
geloczi committed Dec 19, 2021
1 parent 639add2 commit d33badc
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public async Task Genre_List()
public async Task Song_ListWith_song_rating() => await ListSongs(SongQueryAdditional.song_rating);
[TestMethod]
public async Task Song_ListWith_song_tag() => await ListSongs(SongQueryAdditional.song_tag);

private async Task ListSongs(SongQueryAdditional queryAdditional)
{
var response = await AudioStation.ListSongsAsync(TestPageSize, 0, queryAdditional);
Expand Down Expand Up @@ -452,6 +452,21 @@ public async Task SetFileTags()
Assert.IsTrue((await AudioStation.SetSongFileTags(change)).Success);
}

// This is tested manually
//[TestMethod]
//public async Task TestReIndex()
//{
// // Start reindexing
// var startReIndexResponse = await AudioStation.StartReIndex();
// Assert.IsTrue(startReIndexResponse.Success);

// // Check reindexing state
// Thread.Sleep(100);
// var getReIndexStateResponse = await AudioStation.GetReIndexState();
// Assert.IsTrue(getReIndexStateResponse.Success);
// Assert.IsTrue(getReIndexStateResponse.ReIndexing);
//}

#region Private Methods
private static void AssertSong(Song song, SongQueryAdditional additional)
{
Expand Down
34 changes: 34 additions & 0 deletions SynologyDotNet.AudioStation/AudioStationClient.Management.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Threading.Tasks;
using SynologyDotNet.AudioStation.Model;
using SynologyDotNet.Core.Helpers;
using SynologyDotNet.Core.Responses;

namespace SynologyDotNet.AudioStation
{
public partial class AudioStationClient
{
private const string UsermanEndpoint = "webman/3rdparty/AudioStation/webUI/audio_userman.cgi";

/// <summary>
/// Starts indexing service to update audio library.
/// </summary>
/// <returns></returns>
public async Task<ApiResponse> StartReIndex()
{
var req = new RequestBuilder().SetEndpoint(UsermanEndpoint);
req["action"] = "do_reindex";
return await Client.QueryObjectAsync<ApiResponse>(req);
}

/// <summary>
/// Gets the state of the indexing service.
/// </summary>
/// <returns></returns>
public async Task<ReIndexStateResponse> GetReIndexState()
{
var req = new RequestBuilder().SetEndpoint(UsermanEndpoint);
req["action"] = "load_reindex";
return await Client.QueryObjectAsync<ReIndexStateResponse>(req);
}
}
}
6 changes: 6 additions & 0 deletions SynologyDotNet.AudioStation/AudioStationClient.Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ namespace SynologyDotNet.AudioStation
{
public partial class AudioStationClient
{
/// <summary>
/// This exists only if the AudioStation package has been installed.
/// This endpoint is used to edit song metadata prgorammatically.
/// </summary>
private const string TagEditorEndpoint = "webman/3rdparty/AudioStation/tagEditorUI/tag_editor.cgi";

/// <summary>
/// Query song tags
/// </summary>
Expand Down
12 changes: 1 addition & 11 deletions SynologyDotNet.AudioStation/AudioStationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ namespace SynologyDotNet.AudioStation
/// </summary>
public partial class AudioStationClient : StationConnectorBase
{
#region Fields

/// <summary>
/// This exists only if the AudioStation package has been installed.
/// This endpoint is used to edit song metadata prgorammatically.
/// </summary>
private const string TagEditorEndpoint = "webman/3rdparty/AudioStation/tagEditorUI/tag_editor.cgi";

#endregion Fields

#region Apis

const string SYNO_AudioStation_Info = "SYNO.AudioStation.Info";
Expand Down Expand Up @@ -108,7 +98,7 @@ public async Task<ApiListRessponse<FolderList>> ListFoldersAsync(int limit, int

return await Client.QueryListAsync<ApiListRessponse<FolderList>>(SYNO_AudioStation_Folder, "list", limit, offset, args.ToArray());
}

// Use tageditor instead!
//#region Lyrics
//public async Task<ApiDataResponse<Lyrics>> GetLyricsAsync(string songId)
Expand Down
11 changes: 11 additions & 0 deletions SynologyDotNet.AudioStation/Model/ReIndexStateResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Newtonsoft.Json;
using SynologyDotNet.Core.Responses;

namespace SynologyDotNet.AudioStation.Model
{
public class ReIndexStateResponse : ApiResponse
{
[JsonProperty("reindexing")]
public bool ReIndexing { get; set; }
}
}

0 comments on commit d33badc

Please sign in to comment.