* 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
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Channels;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Core;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Interfaces.Repositories;
|
|
using LanguageExt;
|
|
using MediatR;
|
|
|
|
namespace ErsatzTV.Application.Jellyfin.Commands
|
|
{
|
|
public class SynchronizeJellyfinMediaSourcesHandler : IRequestHandler<SynchronizeJellyfinMediaSources,
|
|
Either<BaseError, List<JellyfinMediaSource>>>
|
|
{
|
|
private readonly ChannelWriter<IJellyfinBackgroundServiceRequest> _channel;
|
|
private readonly IMediaSourceRepository _mediaSourceRepository;
|
|
|
|
public SynchronizeJellyfinMediaSourcesHandler(
|
|
IMediaSourceRepository mediaSourceRepository,
|
|
ChannelWriter<IJellyfinBackgroundServiceRequest> channel)
|
|
{
|
|
_mediaSourceRepository = mediaSourceRepository;
|
|
_channel = channel;
|
|
}
|
|
|
|
public async Task<Either<BaseError, List<JellyfinMediaSource>>> Handle(
|
|
SynchronizeJellyfinMediaSources request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
List<JellyfinMediaSource> mediaSources = await _mediaSourceRepository.GetAllJellyfin();
|
|
foreach (JellyfinMediaSource mediaSource in mediaSources)
|
|
{
|
|
await _channel.WriteAsync(new SynchronizeJellyfinAdminUserId(mediaSource.Id), cancellationToken);
|
|
await _channel.WriteAsync(new SynchronizeJellyfinLibraries(mediaSource.Id), cancellationToken);
|
|
}
|
|
|
|
return mediaSources;
|
|
}
|
|
}
|
|
}
|