* properly scope jellyfin disconnect * add emby entities * add emby media source page * add emby media source editor * sync emby libraries * enable emby library sync toggle * add emby path replacements editor * add emby movie synchronization * fix emby artwork * sync emby television * code cleanup * add jellyfin/emby address placeholder * tweak jellyfin/emby address form
27 lines
913 B
C#
27 lines
913 B
C#
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Core;
|
|
using ErsatzTV.Core.Emby;
|
|
using ErsatzTV.Core.Interfaces.Emby;
|
|
using LanguageExt;
|
|
using Newtonsoft.Json;
|
|
using static LanguageExt.Prelude;
|
|
|
|
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 embySecrets) =>
|
|
Some(JsonConvert.SerializeObject(embySecrets)).Match(
|
|
s => File.WriteAllTextAsync(FileSystemLayout.EmbySecretsPath, s).ToUnit(),
|
|
Task.FromResult(Unit.Default));
|
|
}
|
|
}
|