< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Audio.MusicGenre
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs
Line coverage
10%
Covered lines: 3
Uncovered lines: 27
Coverable lines: 30
Total lines: 124
Line coverage: 10%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/16/2026 - 12:15:55 AM Line coverage: 0% (0/32) Branch coverage: 0% (0/8) Total lines: 12710/29/2026 - 12:17:11 AM Line coverage: 10% (3/30) Branch coverage: 0% (0/8) Total lines: 124 5/16/2026 - 12:15:55 AM Line coverage: 0% (0/32) Branch coverage: 0% (0/8) Total lines: 12710/29/2026 - 12:17:11 AM Line coverage: 10% (3/30) Branch coverage: 0% (0/8) Total lines: 124

Coverage delta

Coverage delta 10 -10

Metrics

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Text.Json.Serialization;
 8using Jellyfin.Data.Enums;
 9using Jellyfin.Extensions;
 10using Microsoft.Extensions.Logging;
 11
 12namespace MediaBrowser.Controller.Entities.Audio
 13{
 14    /// <summary>
 15    /// Class MusicGenre.
 16    /// </summary>
 17    [Common.RequiresSourceSerialisation]
 18    public class MusicGenre : BaseItem, IItemByName
 19    {
 20        [JsonIgnore]
 021        public override bool SupportsAddingToPlaylist => true;
 22
 23        [JsonIgnore]
 024        public override bool SupportsAncestors => false;
 25
 26        [JsonIgnore]
 027        public override bool IsDisplayedAsFolder => true;
 28
 29        /// <summary>
 30        /// Gets the folder containing the item.
 31        /// If the item is a folder, it returns the folder itself.
 32        /// </summary>
 33        /// <value>The containing folder path.</value>
 34        [JsonIgnore]
 035        public override string ContainingFolderPath => Path;
 36
 37        [JsonIgnore]
 038        public override bool SupportsPeople => false;
 39
 40        public override List<string> GetUserDataKeys()
 41        {
 042            var list = base.GetUserDataKeys();
 43
 044            list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
 045            return list;
 46        }
 47
 48        public override string CreatePresentationUniqueKey()
 49        {
 050            return GetUserDataKeys()[0];
 51        }
 52
 53        public override double GetDefaultPrimaryImageAspectRatio()
 54        {
 055            return 1;
 56        }
 57
 58        public override bool CanDelete()
 59        {
 060            return false;
 61        }
 62
 63        public override bool IsSaveLocalMetadataEnabled()
 64        {
 065            return true;
 66        }
 67
 68        public IReadOnlyList<BaseItem> GetTaggedItems(InternalItemsQuery query)
 69        {
 170            query.GenreIds = new[] { Id };
 171            query.IncludeItemTypes = new[] { BaseItemKind.MusicVideo, BaseItemKind.Audio, BaseItemKind.MusicAlbum, BaseI
 72
 173            return LibraryManager.GetItemList(query);
 74        }
 75
 76        public static string GetPath(string name)
 77        {
 078            return GetPath(name, true);
 79        }
 80
 81        public static string GetPath(string name, bool normalizeName)
 82        {
 083            var validName = normalizeName ? GetItemByNameFolderName(name) : name;
 84
 085            return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.MusicGenrePath, validName);
 86        }
 87
 88        private string GetRebasedPath()
 89        {
 090            return GetPath(System.IO.Path.GetFileName(Path), false);
 91        }
 92
 93        public override bool RequiresRefresh()
 94        {
 095            var newPath = GetRebasedPath();
 096            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 97            {
 098                Logger.LogDebug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath);
 099                return true;
 100            }
 101
 0102            return base.RequiresRefresh();
 103        }
 104
 105        /// <summary>
 106        /// This is called before any metadata refresh and returns true or false indicating if changes were made.
 107        /// </summary>
 108        /// <param name="replaceAllMetadata">Option to replace metadata.</param>
 109        /// <returns>True if metadata changed.</returns>
 110        public override bool BeforeMetadataRefresh(bool replaceAllMetadata)
 111        {
 0112            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetadata);
 113
 0114            var newPath = GetRebasedPath();
 0115            if (!string.Equals(Path, newPath, StringComparison.Ordinal))
 116            {
 0117                Path = newPath;
 0118                hasChanges = true;
 119            }
 120
 0121            return hasChanges;
 122        }
 123    }
 124}