< Summary - Jellyfin

Information
Class: MediaBrowser.Providers.Playlists.PlaylistMetadataService
Assembly: MediaBrowser.Providers
File(s): /srv/git/jellyfin/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs
Line coverage
11%
Covered lines: 2
Uncovered lines: 16
Coverable lines: 18
Total lines: 88
Line coverage: 11.1%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_EnableUpdatingGenresFromChildren()100%210%
get_EnableUpdatingOfficialRatingFromChildren()100%210%
get_EnableUpdatingStudiosFromChildren()100%210%
GetChildrenForMetadataUpdates(...)100%210%
MergeData(...)0%110100%

File(s)

/srv/git/jellyfin/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3using MediaBrowser.Controller.Configuration;
 4using MediaBrowser.Controller.Entities;
 5using MediaBrowser.Controller.IO;
 6using MediaBrowser.Controller.Library;
 7using MediaBrowser.Controller.Persistence;
 8using MediaBrowser.Controller.Playlists;
 9using MediaBrowser.Controller.Providers;
 10using MediaBrowser.Model.Entities;
 11using MediaBrowser.Model.IO;
 12using MediaBrowser.Providers.Manager;
 13using Microsoft.Extensions.Logging;
 14
 15namespace MediaBrowser.Providers.Playlists;
 16
 17/// <summary>
 18/// Service to manage playlist metadata.
 19/// </summary>
 20public 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)
 2140        : base(serverConfigurationManager, logger, providerManager, fileSystem, libraryManager, externalDataManager, ite
 41    {
 2142    }
 43
 44    /// <inheritdoc />
 045    protected override bool EnableUpdatingGenresFromChildren => true;
 46
 47    /// <inheritdoc />
 048    protected override bool EnableUpdatingOfficialRatingFromChildren => true;
 49
 50    /// <inheritdoc />
 051    protected override bool EnableUpdatingStudiosFromChildren => true;
 52
 53    /// <inheritdoc />
 54    protected override IReadOnlyList<BaseItem> GetChildrenForMetadataUpdates(Playlist item)
 055        => item.GetLinkedChildren();
 56
 57    /// <inheritdoc />
 58    protected override void MergeData(MetadataResult<Playlist> source, MetadataResult<Playlist> target, MetadataField[] 
 59    {
 060        base.MergeData(source, target, lockedFields, replaceData, mergeMetadataSettings);
 61
 062        var sourceItem = source.Item;
 063        var targetItem = target.Item;
 64
 065        if (mergeMetadataSettings)
 66        {
 067            targetItem.PlaylistMediaType = sourceItem.PlaylistMediaType;
 68
 069            if (replaceData || targetItem.LinkedChildren.Length == 0)
 70            {
 071                targetItem.LinkedChildren = sourceItem.LinkedChildren;
 72            }
 73            else
 74            {
 075                targetItem.LinkedChildren = sourceItem.LinkedChildren.Concat(targetItem.LinkedChildren).Distinct().ToArr
 76            }
 77
 078            if (replaceData || targetItem.Shares.Count == 0)
 79            {
 080                targetItem.Shares = sourceItem.Shares;
 81            }
 82            else
 83            {
 084                targetItem.Shares = sourceItem.Shares.Concat(targetItem.Shares).DistinctBy(s => s.UserId).ToArray();
 85            }
 86        }
 087    }
 88}