#pragma warning disable CS1591 using System.Collections.Generic; using System.Linq; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Providers.Manager; using Microsoft.Extensions.Logging; namespace MediaBrowser.Providers.Playlists { public class PlaylistMetadataService : MetadataService { public PlaylistMetadataService( IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, libraryManager) { } /// protected override bool EnableUpdatingGenresFromChildren => true; /// protected override bool EnableUpdatingOfficialRatingFromChildren => true; /// protected override bool EnableUpdatingStudiosFromChildren => true; /// protected override IList GetChildrenForMetadataUpdates(Playlist item) => item.GetLinkedChildren(); /// protected override void MergeData(MetadataResult source, MetadataResult target, MetadataField[] lockedFields, bool replaceData, bool mergeMetadataSettings) { base.MergeData(source, target, lockedFields, replaceData, mergeMetadataSettings); var sourceItem = source.Item; var targetItem = target.Item; if (mergeMetadataSettings) { targetItem.PlaylistMediaType = sourceItem.PlaylistMediaType; if (replaceData || targetItem.LinkedChildren.Length == 0) { targetItem.LinkedChildren = sourceItem.LinkedChildren; } else { targetItem.LinkedChildren = sourceItem.LinkedChildren.Concat(targetItem.LinkedChildren).Distinct().ToArray(); } if (replaceData || targetItem.Shares.Count == 0) { targetItem.Shares = sourceItem.Shares; } else { targetItem.Shares = sourceItem.Shares.Concat(targetItem.Shares).DistinctBy(s => s.UserId).ToArray(); } } } } }