mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* support .etvignore files to exclude folders (and child folders) from scanner * include top-level folder in scanner * don't always rescan "other" media sources * add metadata/poster refresh button to media cardspull/27/head v0.0.7-prealpha
11 changed files with 112 additions and 15 deletions
@ -0,0 +1,45 @@ |
|||||||
|
using System.Threading; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using ErsatzTV.Core; |
||||||
|
using ErsatzTV.Core.Domain; |
||||||
|
using ErsatzTV.Core.Interfaces.Metadata; |
||||||
|
using ErsatzTV.Core.Interfaces.Repositories; |
||||||
|
using LanguageExt; |
||||||
|
|
||||||
|
namespace ErsatzTV.Application.MediaItems.Commands |
||||||
|
{ |
||||||
|
public class |
||||||
|
RefreshMediaItemPosterHandler : MediatR.IRequestHandler<RefreshMediaItemPoster, |
||||||
|
Either<BaseError, Unit>> |
||||||
|
{ |
||||||
|
private readonly ILocalPosterProvider _localPosterProvider; |
||||||
|
private readonly IMediaItemRepository _mediaItemRepository; |
||||||
|
|
||||||
|
public RefreshMediaItemPosterHandler( |
||||||
|
IMediaItemRepository mediaItemRepository, |
||||||
|
ILocalPosterProvider localPosterProvider) |
||||||
|
{ |
||||||
|
_mediaItemRepository = mediaItemRepository; |
||||||
|
_localPosterProvider = localPosterProvider; |
||||||
|
} |
||||||
|
|
||||||
|
public Task<Either<BaseError, Unit>> Handle( |
||||||
|
RefreshMediaItemPoster request, |
||||||
|
CancellationToken cancellationToken) => |
||||||
|
Validate(request) |
||||||
|
.MapT(RefreshPoster) |
||||||
|
.Bind(v => v.ToEitherAsync()); |
||||||
|
|
||||||
|
private Task<Validation<BaseError, MediaItem>> Validate(RefreshMediaItemPoster request) => |
||||||
|
MediaItemMustExist(request); |
||||||
|
|
||||||
|
private Task<Validation<BaseError, MediaItem>> MediaItemMustExist(RefreshMediaItemPoster request) => |
||||||
|
_mediaItemRepository.Get(request.MediaItemId) |
||||||
|
.Map( |
||||||
|
maybeItem => maybeItem.ToValidation<BaseError>( |
||||||
|
$"[MediaItem] {request.MediaItemId} does not exist.")); |
||||||
|
|
||||||
|
private Task<Unit> RefreshPoster(MediaItem mediaItem) => |
||||||
|
_localPosterProvider.RefreshPoster(mediaItem).ToUnit(); |
||||||
|
} |
||||||
|
} |
||||||
@ -1,4 +1,4 @@ |
|||||||
namespace ErsatzTV.Core.AggregateModels |
namespace ErsatzTV.Core.AggregateModels |
||||||
{ |
{ |
||||||
public record MediaItemSummary(string Title, string SortTitle, string Subtitle, string Poster); |
public record MediaItemSummary(int MediaItemId, string Title, string SortTitle, string Subtitle, string Poster); |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue