protected async Task <bool> UpdateArtworkIfNeeded( Domain.Metadata existingMetadata, Domain.Metadata incomingMetadata, ArtworkKind artworkKind) { if (incomingMetadata.DateUpdated > existingMetadata.DateUpdated) { Option <Artwork> maybeIncomingArtwork = Optional(incomingMetadata.Artwork).Flatten() .Find(a => a.ArtworkKind == artworkKind); if (maybeIncomingArtwork.IsNone) { existingMetadata.Artwork ??= new List <Artwork>(); existingMetadata.Artwork.RemoveAll(a => a.ArtworkKind == artworkKind); await _metadataRepository.RemoveArtwork(existingMetadata, artworkKind); } foreach (Artwork incomingArtwork in maybeIncomingArtwork) { _logger.LogDebug("Refreshing Plex {Attribute} from {Path}", artworkKind, incomingArtwork.Path); Option <Artwork> maybeExistingArtwork = Optional(existingMetadata.Artwork).Flatten() .Find(a => a.ArtworkKind == artworkKind); if (maybeExistingArtwork.IsNone) { existingMetadata.Artwork ??= new List <Artwork>(); existingMetadata.Artwork.Add(incomingArtwork); await _metadataRepository.AddArtwork(existingMetadata, incomingArtwork); } foreach (Artwork existingArtwork in maybeExistingArtwork) { existingArtwork.Path = incomingArtwork.Path; existingArtwork.DateUpdated = incomingArtwork.DateUpdated; await _metadataRepository.UpdateArtworkPath(existingArtwork); } } return(true); } return(false); }
public Task <bool> AddTag(Domain.Metadata metadata, Tag tag) => throw new NotSupportedException();