AuphonicNet is a .NET implementation for the Auphonic Api. It uses .Net Standard 2.1 framework and it accessable from .Net Core as well as from .Net Framework
At the current state you can Query Userdetails, Presets and Productions. You also can create and start productions
The API-Description can be found at Auphonic Help
Start by downloading the source or add the NuGet-Package to your solution.
The first thing you have to do is to provide your credentials:
AuphonicApi.BasicAuth.SetCredentials("username","password").
private async Task GetMyCredits() {
AuphonicApi.BasicAuth.SetCredentials("username", "password");
var query=new AuphonicApi.Query();
var meMyselfAndI=await query.GetUserAsync();
Console.Write($"I have {meMyselfAndI.Data.Credits} credits left");
}
private async Task ShowStuff() {
AuphonicApi.BasicAuth.SetCredentials("username", "password");
var query=new AuphonicApi.Query();
var productions=await query.GetProductionsAsync();
var presets=await query.GetPresetsAsync();
Console.Write("My Presets:");
foreach (var p in presets) {
Console.Write(p.Data.PresetName);
}
Console.Write("My Productions:");
foreach (var p2 in productions) {
Console.Write(p2.Data.MetaData.Title);
}
}
private async Task CreateProduction(string presetUuid, string episodeTitle, byte[] mp3file) {
AuphonicApi.BasicAuth.SetCredentials("username", "password");
var prod=new AuphonicApi.Production();
var production= await prod.CreateFromPreset(presetUuid, episodeTitle);
var productionUuid=production.Data.Uuid;
await prod.AddFileToProduction(productionUuid, "upload.mp3", mp3file);
await prod.StartProduction(productionUuid);
}
private async Task CreateWithHook(string presetUuid, string title, byte[] mp3file) {
AuphonicApi.BasicAuth.SetCredentials("username", "password");
var prod=new AuphonicApi.Production();
var production=await _production.CreateFromPreset(
presetUuid,
new Dictionary<string, object> { { "WebHook", "http://example.com/hook/auphonic" } },
new AuphonicApi.Models.Metadata { Title = title }
);
var productionUuid=production.Data.Uuid;
await prod.AddFileToProduction(productionUuid, "upload.mp3", mp3file);
await prod.StartProduction(productionUuid);
}
Auphonic sends successinformation to any finished production. When using Asp.Net WebApi you can collect the response from the webhook the following way:
[ApiController]
[Route("[controller]")]
public class HookController:ControllerBase
{
[HttpPost]
[Route("auphonic")]
public async void Webhook([FromForm] string uuid, [FromForm(Name ="status_string")] string status, [FromForm(Name ="status")] int statusNumber)
{
if (status=="Done") {
Console.Write($"{uuid} is finished")
} else {
Console.Write($"{uuid} failed")
}
}
}