public async Task <SyncResult> Synchronise(PlexMediaContainer libraryContainer, bool fullRefresh, string authToken, string plexUri, string machineIdentifier) { _logger.LogDebug("Started synchronising Movies"); var syncResult = new SyncResult(); var localMediaItems = await _plexService.GetMediaItems(Type); var localMediaItemsCount = localMediaItems?.Count ?? 0; _logger.LogDebug($"Retrieved '{localMediaItemsCount}' existing media items"); foreach (var remoteMediaItem in libraryContainer.MediaContainer.Metadata) { _logger.LogDebug($"Processing rating key '{remoteMediaItem.RatingKey}'"); var ratingKey = Convert.ToInt32(remoteMediaItem.RatingKey); var retrievedItem = await _mediaItemProcessor.GetMediaItem(ratingKey, Type, localMediaItems, authToken, plexUri, machineIdentifier, _plexSettings.PlexMediaItemUriFormat); _logger.LogDebug($"Finished processing rating key '{remoteMediaItem.RatingKey}'"); if (retrievedItem == null) { continue; } _mediaItemProcessor.UpdateResult(syncResult, retrievedItem.IsNew, retrievedItem.MediaItem); } _logger.LogDebug("Finished synchronising Movies"); return(syncResult); }
private void GivenAMediaItemIsUpdated() { _mediaItemProcessor.UpdateResult(Arg.Any <SyncResult>(), Arg.Any <bool>(), Arg.Do <PlexMediaItemRow>(x => _updatedMediaItem = x)); }