Stream custom live channels using your own media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
755 B

using ErsatzTV.Core;
using ErsatzTV.Core.Emby;
using ErsatzTV.Core.Interfaces.Emby;
using Newtonsoft.Json;
namespace ErsatzTV.Infrastructure.Emby;
public class EmbySecretStore : IEmbySecretStore
{
public Task<Unit> DeleteAll() => SaveSecrets(new EmbySecrets());
public Task<EmbySecrets> ReadSecrets() =>
File.ReadAllTextAsync(FileSystemLayout.EmbySecretsPath)
.Map(JsonConvert.DeserializeObject<EmbySecrets>)
.Map(s => Optional(s).IfNone(new EmbySecrets()));
public Task<Unit> SaveSecrets(EmbySecrets secrets) =>
Some(JsonConvert.SerializeObject(secrets)).Match(
s => File.WriteAllTextAsync(FileSystemLayout.EmbySecretsPath, s).ToUnit(),
Task.FromResult(Unit.Default));
}