| | 1 | | #pragma warning disable CS1591 |
| | 2 | |
|
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Linq; |
| | 5 | | using MediaBrowser.Controller.Configuration; |
| | 6 | | using MediaBrowser.Controller.Entities; |
| | 7 | | using MediaBrowser.Controller.Entities.Movies; |
| | 8 | | using MediaBrowser.Controller.Library; |
| | 9 | | using MediaBrowser.Controller.Providers; |
| | 10 | | using MediaBrowser.Model.Entities; |
| | 11 | | using MediaBrowser.Model.IO; |
| | 12 | | using MediaBrowser.Providers.Manager; |
| | 13 | | using Microsoft.Extensions.Logging; |
| | 14 | |
|
| | 15 | | namespace MediaBrowser.Providers.BoxSets |
| | 16 | | { |
| | 17 | | public class BoxSetMetadataService : MetadataService<BoxSet, BoxSetInfo> |
| | 18 | | { |
| | 19 | | public BoxSetMetadataService( |
| | 20 | | IServerConfigurationManager serverConfigurationManager, |
| | 21 | | ILogger<BoxSetMetadataService> logger, |
| | 22 | | IProviderManager providerManager, |
| | 23 | | IFileSystem fileSystem, |
| | 24 | | ILibraryManager libraryManager) |
| 21 | 25 | | : base(serverConfigurationManager, logger, providerManager, fileSystem, libraryManager) |
| | 26 | | { |
| 21 | 27 | | } |
| | 28 | |
|
| | 29 | | /// <inheritdoc /> |
| 0 | 30 | | protected override bool EnableUpdatingGenresFromChildren => true; |
| | 31 | |
|
| | 32 | | /// <inheritdoc /> |
| 0 | 33 | | protected override bool EnableUpdatingOfficialRatingFromChildren => true; |
| | 34 | |
|
| | 35 | | /// <inheritdoc /> |
| 0 | 36 | | protected override bool EnableUpdatingStudiosFromChildren => true; |
| | 37 | |
|
| | 38 | | /// <inheritdoc /> |
| 0 | 39 | | protected override bool EnableUpdatingPremiereDateFromChildren => true; |
| | 40 | |
|
| | 41 | | /// <inheritdoc /> |
| | 42 | | protected override IReadOnlyList<BaseItem> GetChildrenForMetadataUpdates(BoxSet item) |
| | 43 | | { |
| 0 | 44 | | return item.GetLinkedChildren(); |
| | 45 | | } |
| | 46 | |
|
| | 47 | | /// <inheritdoc /> |
| | 48 | | protected override void MergeData(MetadataResult<BoxSet> source, MetadataResult<BoxSet> target, MetadataField[] |
| | 49 | | { |
| 0 | 50 | | base.MergeData(source, target, lockedFields, replaceData, mergeMetadataSettings); |
| | 51 | |
|
| 0 | 52 | | var sourceItem = source.Item; |
| 0 | 53 | | var targetItem = target.Item; |
| | 54 | |
|
| 0 | 55 | | if (mergeMetadataSettings) |
| | 56 | | { |
| 0 | 57 | | if (replaceData || targetItem.LinkedChildren.Length == 0) |
| | 58 | | { |
| 0 | 59 | | targetItem.LinkedChildren = sourceItem.LinkedChildren; |
| | 60 | | } |
| | 61 | | else |
| | 62 | | { |
| 0 | 63 | | targetItem.LinkedChildren = sourceItem.LinkedChildren.Concat(targetItem.LinkedChildren).Distinct().T |
| | 64 | | } |
| | 65 | | } |
| 0 | 66 | | } |
| | 67 | |
|
| | 68 | | /// <inheritdoc /> |
| | 69 | | protected override ItemUpdateType BeforeSaveInternal(BoxSet item, bool isFullRefresh, ItemUpdateType updateType) |
| | 70 | | { |
| 0 | 71 | | var updatedType = base.BeforeSaveInternal(item, isFullRefresh, updateType); |
| | 72 | |
|
| 0 | 73 | | var libraryFolderIds = item.GetLibraryFolderIds(); |
| | 74 | |
|
| 0 | 75 | | var itemLibraryFolderIds = item.LibraryFolderIds; |
| 0 | 76 | | if (itemLibraryFolderIds is null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds)) |
| | 77 | | { |
| 0 | 78 | | item.LibraryFolderIds = libraryFolderIds; |
| 0 | 79 | | updatedType |= ItemUpdateType.MetadataImport; |
| | 80 | | } |
| | 81 | |
|
| 0 | 82 | | return updatedType; |
| | 83 | | } |
| | 84 | | } |
| | 85 | | } |