| | 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.Library; |
| | 8 | | using MediaBrowser.Controller.Playlists; |
| | 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.Playlists |
| | 16 | | { |
| | 17 | | public class PlaylistMetadataService : MetadataService<Playlist, ItemLookupInfo> |
| | 18 | | { |
| | 19 | | public PlaylistMetadataService( |
| | 20 | | IServerConfigurationManager serverConfigurationManager, |
| | 21 | | ILogger<PlaylistMetadataService> 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 /> |
| | 39 | | protected override IReadOnlyList<BaseItem> GetChildrenForMetadataUpdates(Playlist item) |
| 0 | 40 | | => item.GetLinkedChildren(); |
| | 41 | |
|
| | 42 | | /// <inheritdoc /> |
| | 43 | | protected override void MergeData(MetadataResult<Playlist> source, MetadataResult<Playlist> target, MetadataFiel |
| | 44 | | { |
| 0 | 45 | | base.MergeData(source, target, lockedFields, replaceData, mergeMetadataSettings); |
| | 46 | |
|
| 0 | 47 | | var sourceItem = source.Item; |
| 0 | 48 | | var targetItem = target.Item; |
| | 49 | |
|
| 0 | 50 | | if (mergeMetadataSettings) |
| | 51 | | { |
| 0 | 52 | | targetItem.PlaylistMediaType = sourceItem.PlaylistMediaType; |
| | 53 | |
|
| 0 | 54 | | if (replaceData || targetItem.LinkedChildren.Length == 0) |
| | 55 | | { |
| 0 | 56 | | targetItem.LinkedChildren = sourceItem.LinkedChildren; |
| | 57 | | } |
| | 58 | | else |
| | 59 | | { |
| 0 | 60 | | targetItem.LinkedChildren = sourceItem.LinkedChildren.Concat(targetItem.LinkedChildren).Distinct().T |
| | 61 | | } |
| | 62 | |
|
| 0 | 63 | | if (replaceData || targetItem.Shares.Count == 0) |
| | 64 | | { |
| 0 | 65 | | targetItem.Shares = sourceItem.Shares; |
| | 66 | | } |
| | 67 | | else |
| | 68 | | { |
| 0 | 69 | | targetItem.Shares = sourceItem.Shares.Concat(targetItem.Shares).DistinctBy(s => s.UserId).ToArray(); |
| | 70 | | } |
| | 71 | | } |
| 0 | 72 | | } |
| | 73 | | } |
| | 74 | | } |