| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using System.Linq; |
| | | 3 | | using MediaBrowser.Controller.Configuration; |
| | | 4 | | using MediaBrowser.Controller.Entities; |
| | | 5 | | using MediaBrowser.Controller.IO; |
| | | 6 | | using MediaBrowser.Controller.Library; |
| | | 7 | | using MediaBrowser.Controller.Persistence; |
| | | 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 | | /// <summary> |
| | | 18 | | /// Service to manage playlist metadata. |
| | | 19 | | /// </summary> |
| | | 20 | | public class PlaylistMetadataService : MetadataService<Playlist, ItemLookupInfo> |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// Initializes a new instance of the <see cref="PlaylistMetadataService"/> class. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/>.</param> |
| | | 26 | | /// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param> |
| | | 27 | | /// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param> |
| | | 28 | | /// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param> |
| | | 29 | | /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param> |
| | | 30 | | /// <param name="externalDataManager">Instance of the <see cref="IExternalDataManager"/> interface.</param> |
| | | 31 | | /// <param name="itemRepository">Instance of the <see cref="IItemRepository"/> interface.</param> |
| | | 32 | | public PlaylistMetadataService( |
| | | 33 | | IServerConfigurationManager serverConfigurationManager, |
| | | 34 | | ILogger<PlaylistMetadataService> logger, |
| | | 35 | | IProviderManager providerManager, |
| | | 36 | | IFileSystem fileSystem, |
| | | 37 | | ILibraryManager libraryManager, |
| | | 38 | | IExternalDataManager externalDataManager, |
| | | 39 | | IItemRepository itemRepository) |
| | 21 | 40 | | : base(serverConfigurationManager, logger, providerManager, fileSystem, libraryManager, externalDataManager, ite |
| | | 41 | | { |
| | 21 | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <inheritdoc /> |
| | 0 | 45 | | protected override bool EnableUpdatingGenresFromChildren => true; |
| | | 46 | | |
| | | 47 | | /// <inheritdoc /> |
| | 0 | 48 | | protected override bool EnableUpdatingOfficialRatingFromChildren => true; |
| | | 49 | | |
| | | 50 | | /// <inheritdoc /> |
| | 0 | 51 | | protected override bool EnableUpdatingStudiosFromChildren => true; |
| | | 52 | | |
| | | 53 | | /// <inheritdoc /> |
| | | 54 | | protected override IReadOnlyList<BaseItem> GetChildrenForMetadataUpdates(Playlist item) |
| | 0 | 55 | | => item.GetLinkedChildren(); |
| | | 56 | | |
| | | 57 | | /// <inheritdoc /> |
| | | 58 | | protected override void MergeData(MetadataResult<Playlist> source, MetadataResult<Playlist> target, MetadataField[] |
| | | 59 | | { |
| | 0 | 60 | | base.MergeData(source, target, lockedFields, replaceData, mergeMetadataSettings); |
| | | 61 | | |
| | 0 | 62 | | var sourceItem = source.Item; |
| | 0 | 63 | | var targetItem = target.Item; |
| | | 64 | | |
| | 0 | 65 | | if (mergeMetadataSettings) |
| | | 66 | | { |
| | 0 | 67 | | targetItem.PlaylistMediaType = sourceItem.PlaylistMediaType; |
| | | 68 | | |
| | 0 | 69 | | if (replaceData || targetItem.LinkedChildren.Length == 0) |
| | | 70 | | { |
| | 0 | 71 | | targetItem.LinkedChildren = sourceItem.LinkedChildren; |
| | | 72 | | } |
| | | 73 | | else |
| | | 74 | | { |
| | 0 | 75 | | targetItem.LinkedChildren = sourceItem.LinkedChildren.Concat(targetItem.LinkedChildren).Distinct().ToArr |
| | | 76 | | } |
| | | 77 | | |
| | 0 | 78 | | if (replaceData || targetItem.Shares.Count == 0) |
| | | 79 | | { |
| | 0 | 80 | | targetItem.Shares = sourceItem.Shares; |
| | | 81 | | } |
| | | 82 | | else |
| | | 83 | | { |
| | 0 | 84 | | targetItem.Shares = sourceItem.Shares.Concat(targetItem.Shares).DistinctBy(s => s.UserId).ToArray(); |
| | | 85 | | } |
| | | 86 | | } |
| | 0 | 87 | | } |
| | | 88 | | } |