diff --git a/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs b/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs index 6c0a73b8a..ff22b0cdc 100644 --- a/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs +++ b/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs @@ -53,6 +53,13 @@ namespace MediaBrowser.Controller.FileOrganization /// FileOrganizationResult. FileOrganizationResult GetResult(string id); + /// + /// Gets the result by source path. + /// + /// The path. + /// FileOrganizationResult. + FileOrganizationResult GetResultBySourcePath(string path); + /// /// Saves the result. /// diff --git a/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs b/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs index 065017cce..268490079 100644 --- a/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs +++ b/MediaBrowser.Controller/Providers/IRemoteMetadataProvider.cs @@ -19,6 +19,8 @@ namespace MediaBrowser.Controller.Providers public interface IRemoteSearchProvider where TLookupInfoType : ItemLookupInfo { + string Name { get; } + Task>> GetSearchResults(TLookupInfoType searchInfo, CancellationToken cancellationToken); } @@ -29,4 +31,21 @@ namespace MediaBrowser.Controller.Providers public string ImageUrl { get; set; } } + + public class RemoteSearchQuery + where T : ItemLookupInfo + { + public T SearchInfo { get; set; } + + /// + /// If set will only search within the given provider + /// + public string SearchProviderName { get; set; } + + /// + /// Gets or sets a value indicating whether [include disabled providers]. + /// + /// true if [include disabled providers]; otherwise, false. + public bool IncludeDisabledProviders { get; set; } + } } diff --git a/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs b/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs index e01df6d94..4a3235a42 100644 --- a/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs +++ b/MediaBrowser.Model/FileOrganization/FileOrganizationResult.cs @@ -89,6 +89,12 @@ namespace MediaBrowser.Model.FileOrganization /// The duplicate paths. public List DuplicatePaths { get; set; } + /// + /// Gets or sets the size of the file. + /// + /// The size of the file. + public long FileSize { get; set; } + public FileOrganizationResult() { DuplicatePaths = new List(); diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 19d1e3ba2..a961be960 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -106,16 +106,6 @@ namespace MediaBrowser.Providers.Manager return Task.FromResult(true); } - /// - /// Saves the image. - /// - /// The item. - /// The URL. - /// The resource pool. - /// The type. - /// Index of the image. - /// The cancellation token. - /// Task. public async Task SaveImage(IHasImages item, string url, SemaphoreSlim resourcePool, ImageType type, int? imageIndex, CancellationToken cancellationToken) { var response = await _httpClient.GetResponse(new HttpRequestOptions @@ -130,28 +120,11 @@ namespace MediaBrowser.Providers.Manager .ConfigureAwait(false); } - /// - /// Saves the image. - /// - /// The item. - /// The source. - /// Type of the MIME. - /// The type. - /// Index of the image. - /// The cancellation token. - /// Task. public Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken) { return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, source, mimeType, type, imageIndex, cancellationToken); } - /// - /// Gets the available remote images. - /// - /// The item. - /// The query. - /// The cancellation token. - /// Task{IEnumerable{RemoteImageInfo}}. public async Task> GetAvailableRemoteImages(IHasImages item, RemoteImageQuery query, CancellationToken cancellationToken) { var providers = GetRemoteImageProviders(item, query.IncludeDisabledProviders); @@ -327,7 +300,7 @@ namespace MediaBrowser.Providers.Manager { return false; } - + if (provider is IRemoteImageProvider) { if (Array.IndexOf(options.DisabledImageFetchers, provider.Name) != -1) @@ -397,7 +370,7 @@ namespace MediaBrowser.Providers.Manager // Not configured. Just return some high number to put it at the end. return 100; } - + private int GetDefaultOrder(IMetadataProvider provider) { var hasOrder = provider as IHasOrder; @@ -531,7 +504,7 @@ namespace MediaBrowser.Providers.Manager } private readonly ConcurrentDictionary _fileLocks = new ConcurrentDictionary(); - + /// /// Saves the metadata. /// @@ -613,13 +586,44 @@ namespace MediaBrowser.Providers.Manager } } - //private IEnumerable GetRemoteSearchResults(TLookupType searchInfo, - // CancellationToken cancellationToken) - // where TLookupType : ItemLookupInfo - //{ - // var providers = _metadataProviders.OfType>(); + public async Task>> GetRemoteSearchResults(RemoteSearchQuery searchInfo, + CancellationToken cancellationToken) + where TItemType : BaseItem, new() + where TLookupType : ItemLookupInfo + { + // Give it a dummy path just so that it looks like a file system item + var dummy = new TItemType + { + Path = "C:\\", + // Dummy this up to fool the local trailer check + Parent = new Folder() + }; - //} + var options = GetMetadataOptions(dummy); + + var providers = GetMetadataProvidersInternal(dummy, options, searchInfo.IncludeDisabledProviders) + .OfType>(); + + if (!string.IsNullOrEmpty(searchInfo.SearchProviderName)) + { + providers = providers.Where(i => string.Equals(i.Name, searchInfo.SearchProviderName, StringComparison.OrdinalIgnoreCase)); + } + + foreach (var provider in providers) + { + var results = await provider.GetSearchResults(searchInfo.SearchInfo, cancellationToken).ConfigureAwait(false); + + var list = results.ToList(); + + if (list.Count > 0) + { + return list; + } + } + + // Nothing found + return new List>(); + } } } \ No newline at end of file diff --git a/MediaBrowser.Providers/Photos/PhotoProvider.cs b/MediaBrowser.Providers/Photos/PhotoProvider.cs index 23ad5230d..66344d1d1 100644 --- a/MediaBrowser.Providers/Photos/PhotoProvider.cs +++ b/MediaBrowser.Providers/Photos/PhotoProvider.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Drawing; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; @@ -13,10 +14,12 @@ namespace MediaBrowser.Providers.Photos public class PhotoProvider : ICustomMetadataProvider, IHasChangeMonitor { private readonly ILogger _logger; + private readonly IImageProcessor _imageProcessor; - public PhotoProvider(ILogger logger) + public PhotoProvider(ILogger logger, IImageProcessor imageProcessor) { _logger = logger; + _imageProcessor = imageProcessor; } public Task FetchAsync(Photo item, IDirectoryService directoryService, CancellationToken cancellationToken) @@ -37,9 +40,6 @@ namespace MediaBrowser.Providers.Photos string manufacturer; string model; - int xResolution; - int yResolution; - reader.GetTagValue(ExifTags.FNumber, out aperture); reader.GetTagValue(ExifTags.ExposureTime, out shutterSpeed); reader.GetTagValue(ExifTags.DateTimeOriginal, out dateTaken); @@ -47,9 +47,6 @@ namespace MediaBrowser.Providers.Photos reader.GetTagValue(ExifTags.Make, out manufacturer); reader.GetTagValue(ExifTags.Model, out model); - reader.GetTagValue(ExifTags.XResolution, out xResolution); - reader.GetTagValue(ExifTags.YResolution, out yResolution); - if (dateTaken > DateTime.MinValue) { item.DateCreated = dateTaken; @@ -61,6 +58,10 @@ namespace MediaBrowser.Providers.Photos cameraModel += " "; cameraModel += model ?? string.Empty; + var size = _imageProcessor.GetImageSize(item.Path); + var xResolution = size.Width; + var yResolution = size.Height; + item.Overview = "Taken " + dateTaken.ToString("F") + "\n" + (!string.IsNullOrWhiteSpace(cameraModel) ? "With a " + cameraModel : "") + (aperture > 0 && shutterSpeed > 0 ? " at f" + aperture.ToString(CultureInfo.InvariantCulture) + " and " + PhotoHelper.Dec2Frac(shutterSpeed) + "s" : "") + "\n" diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index a2e094e9a..d4d7f2f21 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -50,7 +50,8 @@ namespace MediaBrowser.Server.Implementations.FileOrganization Date = DateTime.UtcNow, OriginalPath = path, OriginalFileName = Path.GetFileName(path), - Type = FileOrganizerType.Episode + Type = FileOrganizerType.Episode, + FileSize = new FileInfo(path).Length }; var seriesName = TVUtils.GetSeriesNameFromEpisodeFile(path); @@ -102,6 +103,17 @@ namespace MediaBrowser.Server.Implementations.FileOrganization _logger.Warn(msg); } + var previousResult = _organizationService.GetResultBySourcePath(path); + + if (previousResult != null) + { + // Don't keep saving the same result over and over if nothing has changed + if (previousResult.Status == result.Status && result.Status != FileSortingStatus.Success) + { + return previousResult; + } + } + await _organizationService.SaveResult(result, CancellationToken.None).ConfigureAwait(false); return result; diff --git a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs index 518a7bb48..c03ceb6e5 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs @@ -64,6 +64,18 @@ namespace MediaBrowser.Server.Implementations.FileOrganization return _repo.GetResult(id); } + public FileOrganizationResult GetResultBySourcePath(string path) + { + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentNullException("path"); + } + + var id = path.GetMD5().ToString("N"); + + return GetResult(id); + } + public Task DeleteOriginalFile(string resultId) { var result = _repo.GetResult(resultId); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs index 35261dc3b..cba7aba9a 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs @@ -38,11 +38,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers return null; } - protected static string[] ImageExtensions = { ".tiff", ".jpg", ".png", ".aiff" }; + protected static string[] ImageExtensions = { ".tiff", ".jpeg", ".jpg", ".png", ".aiff" }; protected bool IsImageFile(string path) { return !path.EndsWith("folder.jpg", StringComparison.OrdinalIgnoreCase) - && !path.EndsWith("backdrop.jpg", StringComparison.OrdinalIgnoreCase) && ImageExtensions.Any(p => path.EndsWith(p, StringComparison.OrdinalIgnoreCase)); } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs index 86bf0d71c..df32ac021 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteFileOrganizationRepository.cs @@ -49,8 +49,8 @@ namespace MediaBrowser.Server.Implementations.Persistence string[] queries = { - "create table if not exists OrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)", - "create index if not exists idx_OrganizerResults on OrganizerResults(ResultId)", + "create table if not exists FileOrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, FileLength INT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)", + "create index if not exists idx_FileOrganizerResults on FileOrganizerResults(ResultId)", //pragmas "pragma temp_store = memory", @@ -68,11 +68,12 @@ namespace MediaBrowser.Server.Implementations.Persistence private void PrepareStatements() { _saveResultCommand = _connection.CreateCommand(); - _saveResultCommand.CommandText = "replace into OrganizerResults (ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (@ResultId, @OriginalPath, @TargetPath, @OrganizationDate, @Status, @OrganizationType, @StatusMessage, @ExtractedName, @ExtractedYear, @ExtractedSeasonNumber, @ExtractedEpisodeNumber, @ExtractedEndingEpisodeNumber, @DuplicatePaths)"; + _saveResultCommand.CommandText = "replace into FileOrganizerResults (ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (@ResultId, @OriginalPath, @TargetPath, @FileLength, @OrganizationDate, @Status, @OrganizationType, @StatusMessage, @ExtractedName, @ExtractedYear, @ExtractedSeasonNumber, @ExtractedEpisodeNumber, @ExtractedEndingEpisodeNumber, @DuplicatePaths)"; _saveResultCommand.Parameters.Add(_saveResultCommand, "@ResultId"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@OriginalPath"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@TargetPath"); + _saveResultCommand.Parameters.Add(_saveResultCommand, "@FileLength"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@OrganizationDate"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@Status"); _saveResultCommand.Parameters.Add(_saveResultCommand, "@OrganizationType"); @@ -85,12 +86,12 @@ namespace MediaBrowser.Server.Implementations.Persistence _saveResultCommand.Parameters.Add(_saveResultCommand, "@DuplicatePaths"); _deleteResultCommand = _connection.CreateCommand(); - _deleteResultCommand.CommandText = "delete from OrganizerResults where ResultId = @ResultId"; + _deleteResultCommand.CommandText = "delete from FileOrganizerResults where ResultId = @ResultId"; _deleteResultCommand.Parameters.Add(_saveResultCommand, "@ResultId"); _deleteAllCommand = _connection.CreateCommand(); - _deleteAllCommand.CommandText = "delete from OrganizerResults"; + _deleteAllCommand.CommandText = "delete from FileOrganizerResults"; } public async Task SaveResult(FileOrganizationResult result, CancellationToken cancellationToken) @@ -110,19 +111,22 @@ namespace MediaBrowser.Server.Implementations.Persistence { transaction = _connection.BeginTransaction(); - _saveResultCommand.GetParameter(0).Value = new Guid(result.Id); - _saveResultCommand.GetParameter(1).Value = result.OriginalPath; - _saveResultCommand.GetParameter(2).Value = result.TargetPath; - _saveResultCommand.GetParameter(3).Value = result.Date; - _saveResultCommand.GetParameter(4).Value = result.Status.ToString(); - _saveResultCommand.GetParameter(5).Value = result.Type.ToString(); - _saveResultCommand.GetParameter(6).Value = result.StatusMessage; - _saveResultCommand.GetParameter(7).Value = result.ExtractedName; - _saveResultCommand.GetParameter(8).Value = result.ExtractedYear; - _saveResultCommand.GetParameter(9).Value = result.ExtractedSeasonNumber; - _saveResultCommand.GetParameter(10).Value = result.ExtractedEpisodeNumber; - _saveResultCommand.GetParameter(11).Value = result.ExtractedEndingEpisodeNumber; - _saveResultCommand.GetParameter(12).Value = string.Join("|", result.DuplicatePaths.ToArray()); + var index = 0; + + _saveResultCommand.GetParameter(index++).Value = new Guid(result.Id); + _saveResultCommand.GetParameter(index++).Value = result.OriginalPath; + _saveResultCommand.GetParameter(index++).Value = result.TargetPath; + _saveResultCommand.GetParameter(index++).Value = result.FileSize; + _saveResultCommand.GetParameter(index++).Value = result.Date; + _saveResultCommand.GetParameter(index++).Value = result.Status.ToString(); + _saveResultCommand.GetParameter(index++).Value = result.Type.ToString(); + _saveResultCommand.GetParameter(index++).Value = result.StatusMessage; + _saveResultCommand.GetParameter(index++).Value = result.ExtractedName; + _saveResultCommand.GetParameter(index++).Value = result.ExtractedYear; + _saveResultCommand.GetParameter(index++).Value = result.ExtractedSeasonNumber; + _saveResultCommand.GetParameter(index++).Value = result.ExtractedEpisodeNumber; + _saveResultCommand.GetParameter(index++).Value = result.ExtractedEndingEpisodeNumber; + _saveResultCommand.GetParameter(index).Value = string.Join("|", result.DuplicatePaths.ToArray()); _saveResultCommand.Transaction = transaction; @@ -271,11 +275,11 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var cmd = _connection.CreateCommand()) { - cmd.CommandText = "SELECT ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from OrganizerResults"; + cmd.CommandText = "SELECT ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults"; if (query.StartIndex.HasValue && query.StartIndex.Value > 0) { - cmd.CommandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM OrganizerResults ORDER BY OrganizationDate desc LIMIT {0})", + cmd.CommandText += string.Format(" WHERE ResultId NOT IN (SELECT ResultId FROM FileOrganizerResults ORDER BY OrganizationDate desc LIMIT {0})", query.StartIndex.Value.ToString(_usCulture)); } @@ -286,7 +290,7 @@ namespace MediaBrowser.Server.Implementations.Persistence cmd.CommandText += " LIMIT " + query.Limit.Value.ToString(_usCulture); } - cmd.CommandText += "; select count (ResultId) from OrganizerResults"; + cmd.CommandText += "; select count (ResultId) from FileOrganizerResults"; var list = new List(); var count = 0; @@ -323,7 +327,7 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var cmd = _connection.CreateCommand()) { - cmd.CommandText = "select ResultId, OriginalPath, TargetPath, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from OrganizerResults where ResultId=@Id"; + cmd.CommandText = "select ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults where ResultId=@Id"; cmd.Parameters.Add(cmd, "@Id", DbType.Guid).Value = guid; @@ -341,60 +345,79 @@ namespace MediaBrowser.Server.Implementations.Persistence public FileOrganizationResult GetResult(IDataReader reader) { + var index = 0; + var result = new FileOrganizationResult { Id = reader.GetGuid(0).ToString("N") }; - if (!reader.IsDBNull(1)) + index++; + if (!reader.IsDBNull(index)) { - result.OriginalPath = reader.GetString(1); + result.OriginalPath = reader.GetString(index); } - if (!reader.IsDBNull(2)) + index++; + if (!reader.IsDBNull(index)) { - result.TargetPath = reader.GetString(2); + result.TargetPath = reader.GetString(index); } - result.Date = reader.GetDateTime(3).ToUniversalTime(); - result.Status = (FileSortingStatus)Enum.Parse(typeof(FileSortingStatus), reader.GetString(4), true); - result.Type = (FileOrganizerType)Enum.Parse(typeof(FileOrganizerType), reader.GetString(5), true); + index++; + result.FileSize = reader.GetInt64(index); - if (!reader.IsDBNull(6)) + index++; + result.Date = reader.GetDateTime(index).ToUniversalTime(); + + index++; + result.Status = (FileSortingStatus)Enum.Parse(typeof(FileSortingStatus), reader.GetString(index), true); + + index++; + result.Type = (FileOrganizerType)Enum.Parse(typeof(FileOrganizerType), reader.GetString(index), true); + + index++; + if (!reader.IsDBNull(index)) { - result.StatusMessage = reader.GetString(6); + result.StatusMessage = reader.GetString(index); } result.OriginalFileName = Path.GetFileName(result.OriginalPath); - if (!reader.IsDBNull(7)) + index++; + if (!reader.IsDBNull(index)) { - result.ExtractedName = reader.GetString(7); + result.ExtractedName = reader.GetString(index); } - if (!reader.IsDBNull(8)) + index++; + if (!reader.IsDBNull(index)) { - result.ExtractedYear = reader.GetInt32(8); + result.ExtractedYear = reader.GetInt32(index); } - if (!reader.IsDBNull(9)) + index++; + if (!reader.IsDBNull(index)) { - result.ExtractedSeasonNumber = reader.GetInt32(9); + result.ExtractedSeasonNumber = reader.GetInt32(index); } - if (!reader.IsDBNull(10)) + index++; + if (!reader.IsDBNull(index)) { - result.ExtractedEpisodeNumber = reader.GetInt32(10); + result.ExtractedEpisodeNumber = reader.GetInt32(index); } - if (!reader.IsDBNull(11)) + index++; + if (!reader.IsDBNull(index)) { - result.ExtractedEndingEpisodeNumber = reader.GetInt32(11); + result.ExtractedEndingEpisodeNumber = reader.GetInt32(index); } - if (!reader.IsDBNull(12)) + index++; + if (!reader.IsDBNull(index)) { - result.DuplicatePaths = reader.GetString(12).Split('|').Where(i => !string.IsNullOrEmpty(i)).ToList(); + result.DuplicatePaths = reader.GetString(index).Split('|').Where(i => !string.IsNullOrEmpty(i)).ToList(); } return result;