< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.Audio.Audio
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/Audio/Audio.cs
Line coverage
13%
Covered lines: 5
Uncovered lines: 33
Coverable lines: 38
Total lines: 153
Line coverage: 13.1%
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

Metrics

File(s)

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

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CA1002, CA1724, CA1826, CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.ComponentModel;
 8using System.Globalization;
 9using System.Linq;
 10using System.Text.Json.Serialization;
 11using Jellyfin.Data.Enums;
 12using MediaBrowser.Controller.Providers;
 13using MediaBrowser.Model.Dto;
 14
 15namespace MediaBrowser.Controller.Entities.Audio
 16{
 17    /// <summary>
 18    /// Class Audio.
 19    /// </summary>
 20    public class Audio : BaseItem,
 21        IHasAlbumArtist,
 22        IHasArtist,
 23        IHasMusicGenres,
 24        IHasLookupInfo<SongInfo>,
 25        IHasMediaSources
 26    {
 9927        public Audio()
 28        {
 9929            Artists = Array.Empty<string>();
 9930            AlbumArtists = Array.Empty<string>();
 9931            LyricFiles = Array.Empty<string>();
 9932        }
 33
 34        /// <inheritdoc />
 35        [JsonIgnore]
 36        public IReadOnlyList<string> Artists { get; set; }
 37
 38        /// <inheritdoc />
 39        [JsonIgnore]
 40        public IReadOnlyList<string> AlbumArtists { get; set; }
 41
 42        [JsonIgnore]
 043        public override bool SupportsPlayedStatus => true;
 44
 45        [JsonIgnore]
 046        public override bool SupportsPeople => true;
 47
 48        [JsonIgnore]
 049        public override bool SupportsAddingToPlaylist => true;
 50
 51        [JsonIgnore]
 052        public override bool SupportsInheritedParentImages => true;
 53
 54        [JsonIgnore]
 055        protected override bool SupportsOwnedItems => false;
 56
 57        [JsonIgnore]
 058        public override Folder LatestItemsIndexContainer => AlbumEntity;
 59
 60        [JsonIgnore]
 061        public MusicAlbum AlbumEntity => FindParent<MusicAlbum>();
 62
 63        /// <summary>
 64        /// Gets the type of the media.
 65        /// </summary>
 66        /// <value>The type of the media.</value>
 67        [JsonIgnore]
 068        public override MediaType MediaType => MediaType.Audio;
 69
 70        /// <summary>
 71        /// Gets or sets a value indicating whether this audio has lyrics.
 72        /// </summary>
 73        public bool? HasLyrics { get; set; }
 74
 75        /// <summary>
 76        /// Gets or sets the list of lyric paths.
 77        /// </summary>
 78        public IReadOnlyList<string> LyricFiles { get; set; }
 79
 80        public override double GetDefaultPrimaryImageAspectRatio()
 81        {
 082            return 1;
 83        }
 84
 85        public override bool CanDownload()
 86        {
 087            return IsFileProtocol;
 88        }
 89
 90        /// <summary>
 91        /// Creates the name of the sort.
 92        /// </summary>
 93        /// <returns>System.String.</returns>
 94        protected override string CreateSortName()
 95        {
 096            return (ParentIndexNumber is not null ? ParentIndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCul
 097                    + (IndexNumber is not null ? IndexNumber.Value.ToString("0000 - ", CultureInfo.InvariantCulture) : s
 98        }
 99
 100        public override List<string> GetUserDataKeys()
 101        {
 0102            var list = base.GetUserDataKeys();
 103
 0104            var songKey = IndexNumber.HasValue ? IndexNumber.Value.ToString("0000", CultureInfo.InvariantCulture) : stri
 105
 0106            if (ParentIndexNumber.HasValue)
 107            {
 0108                songKey = ParentIndexNumber.Value.ToString("0000", CultureInfo.InvariantCulture) + "-" + songKey;
 109            }
 110
 0111            songKey += Name;
 112
 0113            if (!string.IsNullOrEmpty(Album))
 114            {
 0115                songKey = Album + "-" + songKey;
 116            }
 117
 0118            var albumArtist = AlbumArtists.FirstOrDefault();
 0119            if (!string.IsNullOrEmpty(albumArtist))
 120            {
 0121                songKey = albumArtist + "-" + songKey;
 122            }
 123
 0124            list.Insert(0, songKey);
 125
 0126            return list;
 127        }
 128
 129        public override UnratedItem GetBlockUnratedType()
 130        {
 0131            if (SourceType == SourceType.Library)
 132            {
 0133                return UnratedItem.Music;
 134            }
 135
 0136            return base.GetBlockUnratedType();
 137        }
 138
 139        public SongInfo GetLookupInfo()
 140        {
 0141            var info = GetItemLookupInfo<SongInfo>();
 142
 0143            info.AlbumArtists = AlbumArtists;
 0144            info.Album = Album;
 0145            info.Artists = Artists;
 146
 0147            return info;
 148        }
 149
 150        protected override IEnumerable<(BaseItem Item, MediaSourceType MediaSourceType)> GetAllItemsForMediaSources()
 0151            => new[] { ((BaseItem)this, MediaSourceType.Default) };
 152    }
 153}