< Summary - Jellyfin

Information
Class: MediaBrowser.Providers.Playlists.PlaylistMetadataService
Assembly: MediaBrowser.Providers
File(s): /srv/git/jellyfin/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs
Line coverage
8%
Covered lines: 2
Uncovered lines: 21
Coverable lines: 23
Total lines: 100
Line coverage: 8.6%
Branch coverage
0%
Covered branches: 0
Total branches: 14
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 1/23/2026 - 12:11:06 AM Line coverage: 11.1% (2/18) Branch coverage: 0% (0/10) Total lines: 885/4/2026 - 12:15:16 AM Line coverage: 8.6% (2/23) Branch coverage: 0% (0/14) Total lines: 100 1/23/2026 - 12:11:06 AM Line coverage: 11.1% (2/18) Branch coverage: 0% (0/10) Total lines: 885/4/2026 - 12:15:16 AM Line coverage: 8.6% (2/23) Branch coverage: 0% (0/14) Total lines: 100

Coverage delta

Coverage delta 3 -3

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%210140%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using MediaBrowser.Controller.Configuration;
 5using MediaBrowser.Controller.Entities;
 6using MediaBrowser.Controller.IO;
 7using MediaBrowser.Controller.Library;
 8using MediaBrowser.Controller.Persistence;
 9using MediaBrowser.Controller.Playlists;
 10using MediaBrowser.Controller.Providers;
 11using MediaBrowser.Model.Entities;
 12using MediaBrowser.Model.IO;
 13using MediaBrowser.Providers.Manager;
 14using Microsoft.Extensions.Logging;
 15
 16namespace MediaBrowser.Providers.Playlists;
 17
 18/// <summary>
 19/// Service to manage playlist metadata.
 20/// </summary>
 21public class PlaylistMetadataService : MetadataService<Playlist, ItemLookupInfo>
 22{
 23    /// <summary>
 24    /// Initializes a new instance of the <see cref="PlaylistMetadataService"/> class.
 25    /// </summary>
 26    /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/>.</param>
 27    /// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
 28    /// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
 29    /// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
 30    /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
 31    /// <param name="externalDataManager">Instance of the <see cref="IExternalDataManager"/> interface.</param>
 32    /// <param name="itemRepository">Instance of the <see cref="IItemRepository"/> interface.</param>
 33    public PlaylistMetadataService(
 34        IServerConfigurationManager serverConfigurationManager,
 35        ILogger<PlaylistMetadataService> logger,
 36        IProviderManager providerManager,
 37        IFileSystem fileSystem,
 38        ILibraryManager libraryManager,
 39        IExternalDataManager externalDataManager,
 40        IItemRepository itemRepository)
 2141        : base(serverConfigurationManager, logger, providerManager, fileSystem, libraryManager, externalDataManager, ite
 42    {
 2143    }
 44
 45    /// <inheritdoc />
 046    protected override bool EnableUpdatingGenresFromChildren => true;
 47
 48    /// <inheritdoc />
 049    protected override bool EnableUpdatingOfficialRatingFromChildren => true;
 50
 51    /// <inheritdoc />
 052    protected override bool EnableUpdatingStudiosFromChildren => true;
 53
 54    /// <inheritdoc />
 55    protected override IReadOnlyList<BaseItem> GetChildrenForMetadataUpdates(Playlist item)
 056        => item.GetLinkedChildren();
 57
 58    /// <inheritdoc />
 59    protected override void MergeData(MetadataResult<Playlist> source, MetadataResult<Playlist> target, MetadataField[] 
 60    {
 061        base.MergeData(source, target, lockedFields, replaceData, mergeMetadataSettings);
 62
 063        var sourceItem = source.Item;
 064        var targetItem = target.Item;
 65
 066        if (mergeMetadataSettings)
 67        {
 068            targetItem.PlaylistMediaType = sourceItem.PlaylistMediaType;
 69
 70            // Only merge LinkedChildren from metadata for external playlists (not managed by Jellyfin).
 71            // For internal playlists, the database LinkedChildren table is the source of truth.
 072            var targetPath = targetItem.Path;
 073            if (!string.IsNullOrEmpty(targetPath)
 074                && !FileSystem.ContainsSubPath(ServerConfigurationManager.ApplicationPaths.DataPath, targetPath))
 75            {
 076                if (replaceData || targetItem.LinkedChildren.Length == 0)
 77                {
 078                    targetItem.LinkedChildren = sourceItem.LinkedChildren;
 79                }
 80                else
 81                {
 82#pragma warning disable CS0618 // Type or member is obsolete - fallback for legacy path-based dedup
 083                    targetItem.LinkedChildren = sourceItem.LinkedChildren.Concat(targetItem.LinkedChildren)
 084                        .DistinctBy(i => i.ItemId.HasValue && !i.ItemId.Value.Equals(Guid.Empty) ? i.ItemId.Value.ToStri
 085                        .ToArray();
 86#pragma warning restore CS0618
 87                }
 88            }
 89
 090            if (replaceData || targetItem.Shares.Count == 0)
 91            {
 092                targetItem.Shares = sourceItem.Shares;
 93            }
 94            else
 95            {
 096                targetItem.Shares = sourceItem.Shares.Concat(targetItem.Shares).DistinctBy(s => s.UserId).ToArray();
 97            }
 98        }
 099    }
 100}