Files
ersatztv/ErsatzTV.Infrastructure/Jellyfin/JellyfinSecretStore.cs
T
Jason DoveandGitHub 4d86250630 add jellyfin media source (#185)
* wip

* start to add jellyfin tables to db

* code cleanup

* finish adding jellyfin media source

* sync jellyfin libraries

* display list of jellyfin libraries

* toggle jellyfin library sync

* edit jellyfin path replacements

* noop jellyfin scanners

* get jellyfin admin user id on startup

* implement jellyfin disconnect

* add jellyfin libraries to list; start to query jellyfin library items

* code cleanup

* start to project jellyfin movies

* save new jellyfin movies to db

* basic jellyfin movie update

* load jellyfin actor artwork

* load jellyfin movie poster and fan art

* more jellyfin artwork fixes, sync audio streams

* jellyfin playback sort of works

* skip jellyfin movies that are inaccessible

* use ffprobe for jellyfin movie statistics

* code cleanup

* store jellyfin operating system

* more jellyfin movie updates

* update jellyfin movie poster and fan art

* add jellyfin tv types

* sync jellyfin shows

* sync jellyfin seasons

* sync jellyfin episodes

* remove missing jellyfin television items

* delete empty jellyfin seasons and shows

* fix jellyfin updates

* fix indexing jellyfin movie and show languages
2021-05-15 13:14:17 -05:00

27 lines
969 B
C#

using System.IO;
using System.Threading.Tasks;
using ErsatzTV.Core;
using ErsatzTV.Core.Interfaces.Jellyfin;
using ErsatzTV.Core.Jellyfin;
using LanguageExt;
using Newtonsoft.Json;
using static LanguageExt.Prelude;
namespace ErsatzTV.Infrastructure.Jellyfin
{
public class JellyfinSecretStore : IJellyfinSecretStore
{
public Task<Unit> DeleteAll() => SaveSecrets(new JellyfinSecrets());
public Task<JellyfinSecrets> ReadSecrets() =>
File.ReadAllTextAsync(FileSystemLayout.JellyfinSecretsPath)
.Map(JsonConvert.DeserializeObject<JellyfinSecrets>)
.Map(s => Optional(s).IfNone(new JellyfinSecrets()));
public Task<Unit> SaveSecrets(JellyfinSecrets jellyfinSecrets) =>
Some(JsonConvert.SerializeObject(jellyfinSecrets)).Match(
s => File.WriteAllTextAsync(FileSystemLayout.JellyfinSecretsPath, s).ToUnit(),
Task.FromResult(Unit.Default));
}
}